Jump to content

how work dll with AutoIt


Luigi
 Share

Recommended Posts

Hi forum!

I found this article, teaches "how create a dll" and work with AutoIt.

sorry my newbie questions

The doubt is:

1) I can store some variable in the DLL?

2) if I can save this variable, what is the life cicle? (until: scripting is running? pc power off? dll unload?)

3) the dll use in AutoIt, can be load and unload?

4) what is happend when script is closed whitout unload dll?

Regards, Luigi

Visit my repository

Link to comment
Share on other sites

In layman's terms, you can "store" as much data as you want in dll. Dll uses chunk of memory space of your process, therefore maximum lifetime of some data depends on lifetime of your process. Unloading the dll frees reserved chunk and renders used memory invalid. You can unload a dll at any time, and if you don't do that AutoIt will do it for you by default before it terminates.

You can not store variable. You can store data that variable holds.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

 

for example, if is possible writhe this simple code inside DLL, read the var's value is not possible?

the method "sum" work fine, and return the correct operation, but, not store the var value, it is correctly?

I need save the var in other way (ini, sqlite)...

global $var

Func sum($a, $b)
   $var = $a+$b
   Return $var
EndFunc

Func read()
   return $var
EndFunc

 

Visit my repository

Link to comment
Share on other sites

Awesome! Cool! Greate! 

Thank you trancexx! ^^

#include "Stdafx.h"

#include "teste.h"

int var;

extern "C" __declspec(dllexport) int sum(int a, int b){
    var = a + b;
    return var;
}

extern "C" __declspec(dllexport) int read(){
    return var;
}
#include-once
#include <Memory.au3>

Local $sDll = "teste.dll"
Local $TRY
Local $a = 3
Local $b = 4

Local $hDLL = DllOpen("teste.dll")
ConsoleWrite("$hDll[ " & $hDLL & " ] @error[ " & @error & " ] @extended[ " & @extended & " ]" & @LF)

$TRY = DllCall($hDll, "int:cdecl", "sum", "int", $a, "int", $b)

ConsoleWrite("$hDll[ " & $hDLL & " ] @error[ " & @error & " ] @extended[ " & @extended & " ] $TRY[ " & $TRY[0] & " ]" & @LF)

$TRY = DllCall($hDll, "int:cdecl", "read")

ConsoleWrite("$hDll[ " & $hDLL & " ] @error[ " & @error & " ] @extended[ " & @extended & " ] $TRY[ " & $TRY[0] & " ]" & @LF)

DllClose($hDLL)
ConsoleWrite("$hDll[ " & $hDLL & " ] @error[ " & @error & " ] @extended[ " & @extended & " ]" & @LF)

 

Edited by Luigi

Visit my repository

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