Hello,
thank you, but does not work,
debugging show, for example if i take as file name excel.exe,
Module is found, all, ok,
but:
System.IntPtr hIcon = NativeMethods.LoadIcon(hLibrary,
"#32512");
gives back zero.
So, it does not work.
Furthermore the problem seems to be "#32512" .
Think I want to build a tree like explorer and have all icons of all
applications, normal windows exe, exe from dotnet, exe from wpf
applications,
so as explorer get the icons.
Thank you for any help.
Rolf Welskes
"Josip Medved" <jmedved@jmedved.com> schrieb im Newsbeitrag
news:C0D2E100-3E42-4C2B-A2D7-2096C64D6DFC@microsoft.com...
[quoted text, click to view] > BTW. Don't forget to do FreeLibrary like I just did. :)
> Icon dispose would also be nice after you are done with it.
>
> "Josip Medved" <jmedved@jmedved.com> wrote in message
> news:2909F979-7949-4F63-AF71-EA8CE6679299@microsoft.com...
>> Hi,
>>
>> you may want to use interop here.
>>
>> E.g. (works for executables)
>> --
>> System.IntPtr hLibrary = NativeMethods.LoadLibrary(fileName);
>> if (!hLibrary.Equals(System.IntPtr.Zero)) {
>> System.IntPtr hIcon = NativeMethods.LoadIcon(hLibrary, "#32512");
>> if (!hIcon.Equals(System.IntPtr.Zero)) {
>> Icon icon = System.Drawing.Icon.FromHandle(hIcon);
>> }
>> }
>> --
>>
>> private static class NativeMethods {
>>
>> [System.Runtime.InteropServices.DllImport("user32.dll", CharSet =
>> CharSet.Unicode)]
>> static extern internal System.IntPtr LoadIcon(System.IntPtr hInstance,
>> string lpIconName);
>>
>> [System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet =
>> CharSet.Unicode)]
>> static extern internal System.IntPtr LoadLibrary(string lpFileName);
>>
>> }
>>
>>
>>
>>
>> "Rolf Welskes" <rolf@nospam.nospam> wrote in message
>> news:OQvhAnrwIHA.3384@TK2MSFTNGP03.phx.gbl...
>>> Hello,
>>>
>>> I have in windows forms, on the other hand in windows presentation the
>>> following problem:
>>>
>>> I have a program with a list of programs (exe-files).
>>> Now I want to display the (standard) icons of these programs, similiar
>>> as in explorer.
>>>
>>> So, for example I have the pathes:
>>>
>>> f:/aaaa/bbb/office/excel.exe or
>>> f:/aaa/ccc/adobe/premiere.exe
>>>
>>> So I have access to the program files,
>>> but how do I get the (standard) icons of these program files and how do
>>> I use
>>> it in windows forms and in windows presentation foundation?
>>>
>>>
>>> Thank you for any help.
>>>
>>> Best Regards
>>> Rolf Welskes
>>>
>>>
>>
>