bittware Posted July 11, 2010 Share Posted July 11, 2010 (edited) Hello experts, I am new to AutoIt. I looked up the AutoIt help file and didn't find out how to visit DLL export global variable. Could you be so kind to let me know how to do that? A simple example will be very appreciated. BRs, bittware Edited July 11, 2010 by bittware Link to comment Share on other sites More sharing options...
trancexx Posted July 11, 2010 Share Posted July 11, 2010 Rephrase. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
bittware Posted July 12, 2010 Author Share Posted July 12, 2010 Rephrase.I just want to get the value of a global variable which is defined in DLL file. AutoIt DllCall seems not supporting DLL variable visit. Link to comment Share on other sites More sharing options...
AndyG Posted July 12, 2010 Share Posted July 12, 2010 (edited) Hi,$dll = DllOpen("GlobalString_GlobalNumber.dll") ;dll with globals $result = DllCall($dll, "int", "GlobalNumber", "int", 0) global $global_number=$result[0] $result = DllCall($dll, "str", "GlobalString", "str", " ") global $global_string=$result[0] DllClose($dll)works fine for me....Or do you think about a "resource"? Something that you can edit with a resource editor? #386541 could help.../edit/ VB.net example:Dll:Public Class MeineLib Public Shared variablenName As Integer = 655Program:global_number = MeineLib.variablenNameSry, but I don´t know how to do something like this in AutoIt.... Edited July 12, 2010 by AndyG Link to comment Share on other sites More sharing options...
bittware Posted July 12, 2010 Author Share Posted July 12, 2010 Hi,$dll = DllOpen("GlobalString_GlobalNumber.dll") ;dll with globals $result = DllCall($dll, "int", "GlobalNumber", "int", 0) global $global_number=$result[0] $result = DllCall($dll, "str", "GlobalString", "str", " ") global $global_string=$result[0] DllClose($dll)works fine for me.... Or do you think about a "resource"? Something that you can edit with a resource editor? #386541 could help... /edit/ VB.net example: Dll: Public Class MeineLib Public Shared variablenName As Integer = 655 Program: global_number = MeineLib.variablenName Sry, but I don´t know how to do something like this in AutoIt.... AndyG, I've tried your method. But it doesn't work for me. $dll = DllOpen("d:\scripts\sub20.dll") ;dll with globals $result = DllCall($dll, "int", "sub_errno", "int", 0) global $global_number=$result[0] ConsoleWrite($global_number&@CRLF) DllClose($dll) It got crashed... This method seems undocumented in AutoIt help file. The DLL file is attached. In which sub_errno is declared as "extern int"(see libsub.h)libsub.hsub20.dll Link to comment Share on other sites More sharing options...
bittware Posted July 12, 2010 Author Share Posted July 12, 2010 (edited) My question is similar to this post http://www.autoitscript.com/forum/index.php?showtopic=77692&st=0&p=562249&hl=extern%20variable&fromsearch=1&#entry562249 But that post didn't give the accurate answer. Hope someone will help me out. Edited July 12, 2010 by bittware Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 12, 2010 Share Posted July 12, 2010 AutoIt can't access it. It's poor programming in the first place though. If you wrote the dll, return it as a function return instead. If you didn't write it, talk to the programmer or find something better. Link to comment Share on other sites More sharing options...
AndyG Posted July 12, 2010 Share Posted July 12, 2010 Hi, hard stuff is our daily job $dll = DllOpen("sub20.dll") ;dll with globals $result = DllCall($dll, "int:cdecl", "sub_set_debug_level", "int", 1) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $result = ' & $result & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console global $global_number=$result[0] ConsoleWrite($global_number&@CRLF) DllClose($dll)returns something without crash, i didn´t found a function that "init" the device and returns a handle to feed the other functions...btw. i don´t know anything about C/C++/C#. So if Richard says "it does not work", then it does not work... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now