Luigi Posted July 25, 2015 Share Posted July 25, 2015 Hi forum!I found this article, teaches "how create a dll" and work with AutoIt.sorry my newbie questionsThe 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 More sharing options...
trancexx Posted July 25, 2015 Share Posted July 25, 2015 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. Luigi 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Luigi Posted July 25, 2015 Author Share Posted July 25, 2015 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 More sharing options...
trancexx Posted July 25, 2015 Share Posted July 25, 2015 Of course you can do that. You can save, read, change... whatever you want. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Luigi Posted July 25, 2015 Author Share Posted July 25, 2015 (edited) 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 July 25, 2015 by Luigi Visit my repository 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