| View previous topic :: View next topic |
| Author |
Message |
Dave-X
Joined: 24 Oct 2009 Posts: 17
|
Posted: Sat Oct 24, 2009 6:11 pm Post subject: DLLCall & Visual Basic.NET |
|
|
I wrote a very simple DLL in Visual Basic.NET with one single function to return the string it receives to all uppercase.
The VB.Net DLL code is:
| Code: | Public Class Engine
Function Test(ByVal Text As String) As String
Return Text.ToUpper
End Function
End Class |
Now when I tried to DllCall the function from AHK as follows.
| Code: | String_Test := DllCall("Engine.dll\Test", str, "test")
Msgbox %String_Test% |
I also tried.
| Code: | | String_Test := DllCall("Engine.dll\Engine.Test", str, "test") |
Each time I get a -4, "The specified function could not be found inside the DLL"
Can anyone help explain? Thanks! |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Sat Oct 24, 2009 6:52 pm Post subject: |
|
|
Read this:
| Quote: |
Finally, when passing a string-variable to a function that will not change the length of the string, performance is improved by passing the variable by address (e.g. &MyVar) rather than as a "str" (especially when the string is very long). The following example converts a string to uppercase: DllCall("CharUpper", uint, &MyVar)
|
| Code: |
String_Test := DllCall("Engine.dll\Test", uint, &String_Test)
Msgbox %String_Test%
|
Good Luck,  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
Dave-X
Joined: 24 Oct 2009 Posts: 17
|
Posted: Sat Oct 24, 2009 7:01 pm Post subject: |
|
|
Same results. It still fails to even find the function in the DLL, it's as if it's not there. So it's not actually executing any code. Either my syntax is wrong, I'm writing the DLL wrong. Maybe it's the VB.Net language or the fact it's x64?
I'm not sure what's wrong or what I'm doing wrong. |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Sat Oct 24, 2009 7:06 pm Post subject: |
|
|
Did you make a 32 bit DLL
Search the forum for using/creating Dll's
I remember someone wrote a mini help tutorial. _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
Dave-X
Joined: 24 Oct 2009 Posts: 17
|
Posted: Sat Oct 24, 2009 8:33 pm Post subject: |
|
|
No, it's x64 running on x64. Also, I managed to get a -2 error now, using the &String, which is "The return type or one of the specified arg types is invalid. This error can also be caused by passing an expression that evaluates to a number to a string (str) argument."
I recompiled a second version as x86 which did not change any results.  |
|
| Back to top |
|
 |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Sun Oct 25, 2009 8:26 am Post subject: |
|
|
AutoHotkey is currently only 32-bit, so it can only load 32-bit DLL files. I'm not sure how that applies to .NET assemblies though since they work a little differently. In any case, DllCall will only work with unmanaged functions/entry-points. Try CLR.ahk instead.
| Quote: | | Also, I managed to get a -2 error now, using the &String, which is "The return type or one of the specified arg types is invalid. | If DllCall detects a syntax error or invalid type parameter, it will set ErrorLevel to -2 and not even try to load the DLL. |
|
| Back to top |
|
 |
Scratch
Joined: 22 Jan 2009 Posts: 72
|
|
| Back to top |
|
 |
|