Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than shell32, prefix the name with the module name and a period.
<DllImport("shell32")> _
Function SHBindToParent( _
ByVal lpifq As IntPtr, _
ByRef riid As Guid, _
ByRef ppv As IntPtr, _
ByRef pidlLast As IntPtr) As Integer
End Function
VB Signature:
Declare Auto Function SHBindToParent Lib "shell32.dll" ( _
ByVal pidl As IntPtr, _
<[In](), MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, _
ByRef ppv As IntPtr, _
ByRef ppidlLast As IntPtr) As Integer
public static IntPtr NextPIDL(
IntPtr myIntPtr)
{
short cb = Marshal.ReadInt16(myIntPtr);
return new IntPtr((int)myIntPtr + cb);
// must have 'int' here
// it changes the IntPtr myIntPtr
// to 'int', a memory address
}
//---------------------------------
private static int GetPIDLCount(
IntPtr IDList)
{
int Result = 0;
if (IDList != IntPtr.Zero)
{
short cb = Marshal.ReadInt16(IDList);
while (cb != 0)
{
Result++;
IDList = NextPIDL(IDList);
cb = Marshal.ReadInt16(IDList);
}
}
return Result;
}
//---------------------------------
void GetUIObjectOf(
IntPtr hwndOwner,
UInt32 cidl, // number of IntPtr's in incoming array
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)]
IntPtr[] apidl,
[In] ref Guid riid,
UInt32 rgfReserved,
out IntPtr ppv);
/* this version is good if cidl is one
void GetUIObjectOf(
IntPtr hwndOwner,
UInt32 cidl,
ref IntPtr apidl,
[In] ref Guid riid,
UInt32 rgfReserved,
out IntPtr ppv);
*/
void GetDisplayNameOf(
IntPtr pidl,
ESHGDN uFlags,
out STRRET pName);
public enum ESTRRET : int
{
eeRRET_WSTR = 0x0000, // Use STRRET.pOleStr
STRRET_OFFSET = 0x0001, // Use STRRET.uOffset to Ansi
STRRET_CSTR = 0x0002 // Use STRRET.cStr
}
/*
// Microsoft's sample and it works too.
// see sample, Unions.cs
union MYUNION2
{
int i;
char str[128];
};
[ StructLayout( LayoutKind.Explicit, Size=128 )]
public struct MyUnion2_1
{
[ FieldOffset( 0 )]
public int i;
}
*/
// shlobj.h
// this works too...from Unions.cs
[StructLayout(LayoutKind.Explicit, Size=520)]
public struct STRRETinternal
{
[FieldOffset(0)]
public IntPtr pOleStr;
[FieldOffset(0)]
public IntPtr pStr; // LPSTR pStr; NOT USED
[FieldOffset(0)]
public uint uOffset;
}
[StructLayout(LayoutKind.Sequential )]
public struct STRRET
{
public uint uType;
public STRRETinternal data;
}
public class Guid_IShellFolder
{
public static Guid IID_IShellFolder =
new Guid("{000214E6-0000-0000-C000-000000000046}");
}
}
The SHBindToParent API
10/10/2007 5:31:45 PM - -80.31.176.91
ITEMIDLIST - Item ID List for [SHGetSpecialFolderLocation]
2/7/2012 6:53:37 PM - -202.74.138.1
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).