ExtractIconEx - it is not working

  • Thread starter Thread starter news
  • Start date Start date
N

news

Im using this construction, for getting num of icons contained in specified
file. But it is not working. Function returns 0. Where is the problem???

[DllImport("SHELL32.DLL", EntryPoint="ExtractIconEx", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]

public static extern IntPtr ExtractIconEx(string lpszFile, int nIconIndex,
IntPtr phiconLarge, IntPtr phiconSmall, int nIcons);




public void GetIconFromFile()

{

string path = @"C:\WINDOWS\System32\shell32.dll";

IntPtr smallIcon = IntPtr.Zero;

IntPtr largeIcon = IntPtr.Zero;

int i = ExtractIconEx(path , -1, smallIcon, largeIcon , -1).ToInt32();


}



Thanks

M.Endys
 
[DllImport("SHELL32.DLL", EntryPoint="ExtractIconEx", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]

public static extern IntPtr ExtractIconEx(string lpszFile, int nIconIndex,
IntPtr phiconLarge, IntPtr phiconSmall, int nIcons);

Try it like this

[DllImport("SHELL32.DLL", CharSet=CharSet.Auto)]
public static extern int ExtractIconEx(string lpszFile, int
nIconIndex, IntPtr phiconLarge, IntPtr phiconSmall, int nIcons);


int i = ExtractIconEx(path , -1, smallIcon, largeIcon , 0);



Mattias
 
Back
Top