Jump to content

DLL global variable


Recommended Posts

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 by bittware
Link to comment
Share on other sites

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....

Edited by AndyG
Link to comment
Share on other sites

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.h

sub20.dll

Link to comment
Share on other sites

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. :blink:

Edited by bittware
Link to comment
Share on other sites

Hi, hard stuff is our daily job :blink:

$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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...