andrezzz
asked on
in dll module global variable
i have function in dll module :
function SysMsgProc(code : integer; wParam : word; lParam : longint) : longint; stdcall;export;
var
windtext,windtext3, windir,windp: array [0..255] of char;
str,stra,full_date,date_,t ime_,task, DBname:Str ing;
i:integer;
begin
x:=x+1;
log_dll('x - '+x);
date_:=FormatDateTime('yyy y-mm-dd', Date+Time);
time_:=FormatDateTime('hh: nn:ss', Date+Time);
full_date:=FormatDateTime( 'dd/mm/yyy y hh:nn:ss', Date+Time);
Result := CallNextHookEx(SysHook, Code, wParam, lParam);
case code of
HSHELL_WINDOWACTIVATED:
begin
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
GetWindowModuleFileName(Wn d, windp, 255);
task:=ExtractFileName(wind p);
SaveData(buff_date,buff_st art_time,t ime_,buff_ task,buff_ action,buf f_windtext ,buff_othe r);
BufferData(date_,time_,tas k,'OPEN',w indtext,In tToStr(Wnd ));
end;
HSHELL_WINDOWCREATED:
...
see the part where :
x:=x+1;
log_dll('x - '+x);
thx x is declared in var x:integer: at begining of script.
the log_dll functions saves data to have some log data.
see the result log_dll
x - 1
x - 2
x - 3
x - 4
x - 5
x - 6
x - 7
x - 1
x - 2
x - 3
x - 1
x - 1
x - 1
x - 1
x - 2
x - 3
...
the global variable suddenly have number 0 and starts from beginig :/
why in this function (function SysMsgProc(code : integer; wParam : word; lParam : longint) : longint; stdcall;export;)
the global variable suddenly changes. in main programm and other dll file code there isnot used X variable.
how i can create global wariable whitch will be usable in this function and other functions ?
function SysMsgProc(code : integer; wParam : word; lParam : longint) : longint; stdcall;export;
var
windtext,windtext3, windir,windp: array [0..255] of char;
str,stra,full_date,date_,t
i:integer;
begin
x:=x+1;
log_dll('x - '+x);
date_:=FormatDateTime('yyy
time_:=FormatDateTime('hh:
full_date:=FormatDateTime(
Result := CallNextHookEx(SysHook, Code, wParam, lParam);
case code of
HSHELL_WINDOWACTIVATED:
begin
Wnd := wParam;
GetWindowText(Wnd, windtext, 255);
GetWindowModuleFileName(Wn
task:=ExtractFileName(wind
SaveData(buff_date,buff_st
BufferData(date_,time_,tas
end;
HSHELL_WINDOWCREATED:
...
see the part where :
x:=x+1;
log_dll('x - '+x);
thx x is declared in var x:integer: at begining of script.
the log_dll functions saves data to have some log data.
see the result log_dll
x - 1
x - 2
x - 3
x - 4
x - 5
x - 6
x - 7
x - 1
x - 2
x - 3
x - 1
x - 1
x - 1
x - 1
x - 2
x - 3
...
the global variable suddenly have number 0 and starts from beginig :/
why in this function (function SysMsgProc(code : integer; wParam : word; lParam : longint) : longint; stdcall;export;)
the global variable suddenly changes. in main programm and other dll file code there isnot used X variable.
how i can create global wariable whitch will be usable in this function and other functions ?
What type is X declared as?
Are you sure no where else resets the value back to 0?
Are you sure no where else resets the value back to 0?
Yup, if you are freeing the dll and recreating it then it will reset X
keep the global variable in your program and pass it to the DLL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
to mikelittlewood
i can define variable with other name like 'blablabla'. the same effect.
how i can hold the x variable for recreating it ????
to robert_marquardt:
how i can create shared segment to storre this information ???
i can define variable with other name like 'blablabla'. the same effect.
how i can hold the x variable for recreating it ????
to robert_marquardt:
how i can create shared segment to storre this information ???
Follow the link. It contains documentation.
Robert_marqurdt
Alas, your link has been taken over by the keyword advertizers.
Alas, your link has been taken over by the keyword advertizers.
Sorry wrong link, I only saw your last post
I think a good option would be to keep the global variable in your program and pass it to the DLL from your other application like BalckTigerX suggested.
That is not possible for a global hook. A global hook DLL is loaded into all applications.
Regards