app icon in win32

How to get the app icon in win32?
dim p as picture = ?

No plugins, but declares would be all right.
Thanks,
Carlo

What have you tried already that hasn’t worked?

dim p as Picture
dim s as String = app.ExecutableFile.Name + ".icns"
dim f as FolderItem = App.ExecutableFile.Child("Resources").Child(s)
if not f.Exists then
  f = App.ExecutableFile.Child("App.icns")
end if

but f is nil.

Windows doesn’t store the icon in a file like OS X. It’s part of the compiled binary.

I see. Then I’ll provide a custom pct. Thanks,

Looks like the ExtractIconEx function is what you need…

http://winapi.freetechsecrets.com/win32/WIN32ExtractIconEx.htm

only that I dont understand delphi…

ExtractIconEx is in fact a Win32 function of Windows you can use to create a Declare. Here is the page on the Microsoft Developer Network.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms648069(v=vs.85).aspx

Of course, it eventually requires knowing how to build declares for Windows.

Fortunately, Eugene Dakin just completed an excellent book about that :
https://forum.xojo.com/23516-i-wish-i-knew-how-to-implement-win32-declares-with-xojo-on-wind/0
http://great-white-software.com/rblibrary/index.php?main_page=product_info&cPath=16&products_id=135

Nothing wrong about using a picture, though…

I think there is already a declare written for ExtractIconEx in BSLib

Yes, I’ll use a picture, since declares are outside my knowledge.

There is not much that is difficult with declares, unless you are aiming for cross-platform, in which case you need to wrap the appropriate declares for each platform in conditional sections of code. Think of declares as functions in external modules. Only, the modules are system dll’s.

If you can still find it, there was the excellent Visual Basic Developer’s Guide to the Win32 API by Daniel Appleman. You can use the declare examples almost verbatim (sometimes, you have to use CStrings). It is a bit out of date, since it was written at the time of Windowx XP, but most of the win32 API is still usable. You can easily find replacements for deprecated API’s in various web sites, mostly Microsoft’s own.

There are a lot of declares in the Windows Functionality Suite https://github.com/arbp/WFS

Unfortunately, not ExtractIconEX

Indeed, it is there :slight_smile:

Got it. Thnaks.

i threw out a copy of that book (along with about 40 others) about a month ago, having not used it for about 10 years.
one of the most expensive, not to mention heaviest books i owned!

I don’t use it very often either. But like a dictionary, it is handy to have one around from time to time. I threw away everything I had related to VB, except for this one. I find it still relevant and useful even with Windows 10. There are some deprecated API’s, but most are still relevant (the functions were changed, but not the way to call them) and it is easy to adapt the declares to XOJO. It is also a pretty good list of what Win32 calls are available. (not complete anymore, but as I said, mostly relevant)