AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with GetModuleHandle.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jk7800



Joined: 06 Jan 2008
Posts: 40
Location: Gdi+ v1.1

PostPosted: Tue Jul 22, 2008 12:30 pm    Post subject: Problem with GetModuleHandle. Reply with quote

Hi.

I was trying to change change the actual cursor to the one, located in an exe file. But I have problem with getting the module handle of my app. For instance: when I call

Code:
h:=DllCall("GetModuleHandle", Str, "AutoHotkey.exe")
msgbox % DllCall( "GetLastError")


in the AutoHotkey folder, it returns 0 (no errors). But if I copy the autohotkey.exe and rename it to autohotkey2.exe, the following script returns 126, meaning: "Module Not Found".

Code:
h:=DllCall("GetModuleHandle", Str, "AutoHotkey2.exe")
msgbox % DllCall( "GetLastError")


And it doesn't work... Why is it happening?
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Tue Jul 22, 2008 3:36 pm    Post subject: Reply with quote

MSDN wrote:

Retrieves a module handle for the specified module. The module must have been loaded by the calling process.


AFAIK, this means you need to run the exe to get it's handle, or in the case of a dll, use LoadLibrary.

Since autohotkey.exe is running (since your script is running) it returns something. Autohotkey2.exe is not running, so you get an error.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group