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 

Trying to get DLLCALL to work

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
DLLConfused
Guest





PostPosted: Wed Sep 02, 2009 10:28 pm    Post subject: Trying to get DLLCALL to work Reply with quote

I have been trying to figure out the DLLCALL command with no luck. Per the help file it says this can be a DLL of EXE.

Quote:

The DLL or EXE file name followed by a backslash and the name of the function.


So I created a simple function and compiled it into an EXE.

Code:

; Compiled code to testDLLCALL.exe
DLL_Add(X,Y){

value := X + Y

return, value
}


Then a second AHK file that would try and call that function via DLLCALL. Saved to the same location as the EXE my function is in.

Code:

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

Result := DLLCALL("testDLLCALL.exe\DLL_Add", "Int", 3, "Int", 4)

msgbox %ErrorLevel%`n%Result%


I also tried it with a load library call as noted in the help file (I did nto expect this to work but figured I try it just in case)

Code:

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%

hModule := DllCall("LoadLibrary", "str", "testDLLCALL.exe")

Result := DLLCALL("testDLLCALL.exe\DLL_Add", "Int", 3, "Int", 4)

msgbox %ErrorLevel%`n%Result%

DllCall("FreeLibrary", "UInt", hModule)


My errorlevel is returning -4 saying its not finding the function. So It appears I am getting to the file just not the function.

Am I missing some Code in the EXE so it knows the function is there? Is it better to code the EXE/DLL in C, or C++, or another language? Not sure if that would make any difference.
Back to top
DLLConfused
Guest





PostPosted: Wed Sep 02, 2009 10:35 pm    Post subject: Reply with quote

I just thought of this. Because I have it as an EXE wouold I need to have the EXE running?
Back to top
YMP



Joined: 23 Dec 2006
Posts: 418
Location: Russia

PostPosted: Thu Sep 03, 2009 12:38 am    Post subject: Reply with quote

The function should be exported, i.e. be in an exe or dll export table, which is obviously not present in AHK exe's. So, yes, C or C++ would be better.
Back to top
View user's profile Send private message
Display posts from previous:   
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