oh that is really nice, i appreciate your help
i changed the "ExtractAssociatedIconA" to the "SHGetFileInfoA" because the "ExtractAssociatedIconA" only retrieves the middle sized icon and i changed the "DrawIcon" to the "DrawIconEx" command to draw the icon the right size
i applied your suggestion with the memory to get the structure working "SHGetFileInfoA" needs.
new code:
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, May 21, 2017
//set window position 0,0
//set window layout 0,0,0
//set display mode 1920,1080,32
// load DLLs
load dll "Shell32.dll",1
load dll "user32.dll",2
// get the window handle. matrix1 command
//hwnd = GET DBPRO WINDOW()
// because you are loading user32.dll you can use GetActiveWindow to get the window handle. no need for matrix1.
hwnd = call dll(2, "GetActiveWindow")
// some coordinates to pase the icon
x=40
y=40
// without this, it clears the icon right after i call "DrawIcon"
sync on
// paste the path of your testfile here. the "ExtractAssociatedIconA" command should get the icon from this file
path$="C:\Tools\Dark Basic Professional\Projects\pathWalker\skin.bmp"
//path$="C:\Tools\muCommander\muCommander.exe"
// get the hInstance pointer. -6 is the constant GWL_HINSTANCE.
hInstance = call dll(2, "GetWindowLongA", hwnd, -6)
// get the device context
//hdc = call dll(2,"GetWindowDC",hwnd)
// GetDC will return the device context for the window client area only
hdc = call dll(2, "GetDC", hwnd)
// i don't quite understand how this parameter works. i couldn't find any explanation that has nothing to do with the .net framework
//lpiIcon as word
//lpiIcon=3
// lpiIcon is a pointer to a word value
//lpiIcon as dword
//lpiIcon = make memory(2)
//*lpiIcon = 1
// SHFILEINFO structure:
size=4+4+4+259+80
psfi=alloc(size)
// SHGetFileInfoA writes the hIcon handle at the start of SHFILEINFO structure.
someoutput = call dll(1, "SHGetFileInfoA", path$, 0, psfi, size, 0x000000100 or 0x000000001 )
hIcon=peek dword(psfi)
// this draws the icon on the screen.
//call dll 2, "DrawIcon", hdc, x, y, hIcon
call dll 2, "DrawIconEx", hdc, x, y, hIcon, 0, 0, 0, 0, 0x0003 || 0x0004 || 0x0003
// after you use the device context you should release it
call dll 2, "ReleaseDC", hwnd, hdc
call dll 2, "DestroyIcon", hIcon
wait key
// cleanup
free psfi
//delete memory lpiIcon
delete dll 1
delete dll 2
i noticed you added "ReleaseDC" to the code. i didn't know about that. do i need some extra cleanup stuff after the "SHGetFileInfoA" call to keep things clean, before i add this to my app?