[DllImport("Shell32.dll",EntryPoint="ExtractIconExW ",CharSet=CharSet.Unicode,
ExactSpelling=true,CallingConvention=CallingConven tion.StdCall)]
public static extern int ExtractIconEx(string sFile,int iIndex, out IntPtr
piLargeVersion, out IntPtr piSmallVersion, int amountIcons);
public class Foo()
{
IntPtr large, small;
Icon extractedIcon;
ArrayList items;
public Foo()
{
items = new ArrayList();
// Extract Normal folder
ExtractIconEx("Shell32.dll", 3, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
// Extract Open folder
ExtractIconEx("Shell32.dll", 4, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
// Extract A drive
ExtractIconEx("Shell32.dll", 6, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
// Extract Harddisk
ExtractIconEx("Shell32.dll", 8, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
// Extract Network drive
ExtractIconEx("Shell32.dll", 9, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
// Extract CDROM drive
ExtractIconEx("Shell32.dll", 11, out large,out small, 1);
extractedIcon= Icon.FromHandle(small);
items.Add(extractedIcon);
}
}
--
HTH
Kyril Magnos
"I'm not a developer anymore, I'm a software engineer now!" :-)
"Mohammad-Reza" <mr********@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl...
|I try them but it doesn't work.
| Would you please send me a sample code?
| thanks
|
| "Kyril Magnos" <ky**********@yahoo.com> wrote in message
| news:#b**************@TK2MSFTNGP11.phx.gbl...
| > This link might be of some help... :-)
| >
| >
http://www.pinvoke.net/default.aspx/....ExtractIconEx
| >
| > --
| > HTH
| >
| > Kyril Magnos
| > "I'm not a developer anymore, I'm a software engineer now!" :-)
| >
| > "Mohammad-Reza" <mr********@hotmail.com> wrote in message
| > news:eV**************@TK2MSFTNGP11.phx.gbl...
| > | Thanks for your answer
| > | In the api I must send pointer if an interger array to it
| > | then I must use that array in the convert code or use phiconLarge or
| small
| > | directly?
| > |
| > | thanks.
| > |
| > | "Shakir Hussain (C# .NET MCP)" <sh**@fakedomain.com> wrote in message
| > | news:uj**************@tk2msftngp13.phx.gbl...
| > | > Mohammed
| > | >
| > | > You have to convert to icon using the following statement
| > | >
| > | > Icon largeIcon1 = Icon.FromHandle(phiconLarge[0]);
| > | > Icon smallIcon1 = Icon.FromHandle(phiconSmall[0]);
| > | >
| > | > --
| > | > Shak
| > | > C# .NET MCP
| > | > (Houston)
| > | >
| > | >
| > | >
| > | >
| > | > "Mohammad-Reza" <mr********@hotmail.com> wrote in message
| > | > news:#P**************@TK2MSFTNGP12.phx.gbl...
| > | > > Hi
| > | > > I want to extract icon of an exe file and want to know how.
| > | > > I look at the MSDN and find out that I can use ExtractIconEx()
| Windows
| > | API
| > | > > but in there are some changes to that api in c# I made those
| changes
| > | like
| > | > > this :
| > | > > public static extern uint ExtractIconEx(
| > | > >
| > | > > [MarshalAs(UnmanagedType.LPTStr)]
| > | > >
| > | > > string szFile,
| > | > >
| > | > > int nIconIndex,
| > | > >
| > | > > ref int[] phiconLarge,
| > | > >
| > | > > ref int[] phiconSmall,
| > | > >
| > | > > uint nIcons);
| > | > >
| > | > > but its returns and integer array and not an icon.
| > | > >
| > | > > I want to know did I do some thing wrong or I must do something
| > further.
| > | > >
| > | > > Anyway please tell me how I can do this
| > | > >
| > | > > Thanks in advance
| > | > >
| > | > > Mohammad-Reza
| > | > >
| > | > >
| > | >
| > | >
| > |
| > |
| >
| >
|
|