请教
在dll里面写变量让dll里面的函数访问的方法怎样写呢?
这样写可以吗?
library xs1000idll;uses
SysUtils,
Classes,
DllunXS1000I in 'DllunXS1000I.pas';exports
setvalue,getvalue;beginend.// ---------------------------------------------------------
unit DllunXS1000I;interfaceuses
Windows, Messages, SysUtils, Variants, Classes,Controls,Dialogs;function getvalue:Longword;stdcall;
function setvalue(value:Longword):boolean;stdcall;implementationvar
mwhdl:Longword; //这样声明后能否调用?function getvalue:Longword;stdcall;
begin
result:=mwhdl; //这样调用好像是空值。
end;function setvalue(value:Longword):boolean;stdcall;
begin
mwhdl:=value;
end;end.
在dll里面写变量让dll里面的函数访问的方法怎样写呢?
这样写可以吗?
library xs1000idll;uses
SysUtils,
Classes,
DllunXS1000I in 'DllunXS1000I.pas';exports
setvalue,getvalue;beginend.// ---------------------------------------------------------
unit DllunXS1000I;interfaceuses
Windows, Messages, SysUtils, Variants, Classes,Controls,Dialogs;function getvalue:Longword;stdcall;
function setvalue(value:Longword):boolean;stdcall;implementationvar
mwhdl:Longword; //这样声明后能否调用?function getvalue:Longword;stdcall;
begin
result:=mwhdl; //这样调用好像是空值。
end;function setvalue(value:Longword):boolean;stdcall;
begin
mwhdl:=value;
end;end.
可以,但是如果两个不同的应用程序调用同一个Dll的时候,Dll中的变量无法共享,也就是说不要想程序A调用DLL并改变了DLL中的变量值后,程序B可以直接从DLL中获取这个变量的值,它们是处于不同的进程空间的。