Hello,
if I try to call my function:
public static string GetDisplayNameF romPidl(IntPtr Pidl)
{
SHFILEINFOBYTE fileinfobyte = new SHFILEINFOBYTE( true);
try
{
SHGetFileInfoPi dl(
(uint) Pidl,
0,
out fileinfobyte,
(uint) Marshal.SizeOf( fileinfobyte),
SHGFI.SHGFI_PID L | SHGFI.SHGFI_DIS PLAYNAME);
}
// ExecutionEngine Exception
catch(Execution EngineException ex)
{
System.Windows. Forms.MessageBo x.Show(ex.Messa ge);
}
catch(Exception ex)
{
System.Windows. Forms.MessageBo x.Show(ex.Messa ge);
}
return(fileinfo byte.szDisplayN ame);
}
/////////////
dll import:
////////////
[DllImport("shel l32.dll",EntryP oint="SHGetFile InfoA", CharSet=CharSet .Auto)]
private static extern int SHGetFileInfoPi dl(
uint Pidl,
uint FileAttributes,
out SHFILEINFOBYTE fib,
uint FileInfo,
SHGFI Flags);
//////////////////////
Struct SHFILEINFOBYTE
//////////////////////
[StructLayout(La youtKind.Sequen tial)]
private struct SHFILEINFOBYTE
{
public SHFILEINFOBYTE( bool b)
{
hIcon=IntPtr.Ze ro;iIcon=0;dwAt tributes=0;szDi splayName="";sz TypeName="";
}
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
[MarshalAs(Unman agedType.LPStr, SizeConst=260)]
public string szDisplayName;
[MarshalAs(Unman agedType.LPStr, SizeConst=80)]
public string szTypeName;
}
I get an uncatchable ExecutionEngine Exception and my program crashs.
It there any way to bring that to work?
Does anyone know any solutions?
The whole project can be found here:
http://tinyurl.com/62a3y
Thanks,
Benjamin