I wonder what alternatives do I have.
This was my code (that worked until Microsoft broke it):
Code: Select all
gui, 1:add, text, x0 y0 w20 h20, test
gui, 1:-caption hwndH1
gui, 1:show, w500 h500
hModule := DllCall("kernel32\GetModuleHandle", "ptr", "C:\Users\test\Desktop\test.exe", "ptr")
AniCursor := DllCall("LoadImage", "ptr", hModule, "Uint", 5234, "Uint", 0x2, "int", 0, "int", 0, "Uint", zero)
DllCall("SetClassLongPtrW", "ptr", H1, "int", "-12", "ptr", AniCursor)
1_ Create a GUI with a hwnd
2_ Get a handle to the .exe that contains the resource.
3_ Load the animated cursor (resource name: 5234)
4_ Set the Animated cursor on the Gui.
Now I need an alternative to this, I've been playing around with FindResource LoadResource LockResource but I'm stuck.
This is the code:
Code: Select all
gui, 1:add, text, x0 y0 w20 h20, test
gui, 1:-caption hwndH1
gui, 1:show, w500 h500
ResourceLoad(5234)
; I stole this function, I don't remember where I found it.
ResourceLoad(resource)
{
msgbox % hModule := DllCall("kernel32\LoadLibrary", "str", "C:\Users\test\Desktop\test.exe", "ptr")
msgbox % hResource := DllCall("kernel32\FindResource", "ptr", hModule, "ptr", resource, "ptr", 21, "ptr")
msgbox % nSize := DllCall("kernel32\SizeofResource", "ptr", hModule, "ptr", hResource, "Uint")
msgbox % hResData := DllCall("kernel32\LoadResource", "ptr", hModule, "ptr", hResource, "ptr")
msgbox % Buffer := DllCall("kernel32\LockResource", "ptr", hResData, "ptr")
msgbox % hData := DllCall("GlobalAlloc", "uint", 2, "Ptr", nSize, "Ptr")
msgbox % pData := DllCall("GlobalLock", "Ptr", hData, "Ptr")
DllCall("RtlMoveMemory", "Ptr", pData, "Ptr", Buffer, "Ptr", nSize)
DllCall("kernel32\GlobalUnlock", "ptr", hData)
DllCall("ole32\CreateStreamOnHGlobal", "ptr", hData, "int", 1, "UPtr*", pStream)
DllCall("gdiplus\GdipCreateBitmapFromStream", "ptr", pStream, "UPtr*", hBitmap)
return hBitmap
}
From https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagea
How do I get the same but with this alternative? Where should I stop, or what dllcall should I change?...the return value is the handle of the newly loaded image.
I already tried with hResData but it doesn't work.
Thanks in advance.