AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: October 24th, 2009, 7:11 pm 
Offline

Joined: October 24th, 2009, 7:04 pm
Posts: 17
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 7:52 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
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, :o

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:01 pm 
Offline

Joined: October 24th, 2009, 7:04 pm
Posts: 17
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 8:06 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Did you make a 32 bit DLL :?:

Search the forum for using/creating Dll's
I remember someone wrote a mini help tutorial.

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 9:33 pm 
Offline

Joined: October 24th, 2009, 7:04 pm
Posts: 17
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. :|


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 24th, 2009, 10:09 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Here is one of the links.
http://www.autohotkey.com/forum/topic20273.html
http://www.autohotkey.com/forum/topic20765-15.html
http://www.codeproject.com/KB/COM/com_in_c1.aspx#DLL

Quote:
DLLcall also can address a memory location in the Dll instead of
the function name - have you tried this?

http://www.autohotkey.com/forum/viewtopic.php?t=45405

Dll Info
http://www.autohotkey.com/docs/commands/DllCall.htm
http://www.autohotkey.com/forum/topic3687.html
http://www.planet-source-code.com/vb/sc ... &lngWId=10

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 9:26 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Workaround
PostPosted: October 25th, 2009, 5:52 pm 
Offline

Joined: January 22nd, 2009, 3:43 pm
Posts: 84
http://www.autohotkey.com/forum/viewtopic.php?t=21674&highlight=vbs+script

Not quiet DLLish, but independent of 32/64 bit i think...


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: AndyJenk, Bing [Bot], JSLover, Leef_me, patgenn123, rbrtryn, XstatyK 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