AutoHotkey Community

It is currently May 26th, 2012, 10:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 2nd, 2009, 11:28 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2009, 11:35 pm 
I just thought of this. Because I have it as an EXE wouold I need to have the EXE running?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 3rd, 2009, 1:38 am 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, Bing [Bot], JSLover, Leef_me, Miguel, patgenn123, rbrtryn and 70 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group