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.