dll中的程序,多线程调用另外一个dll
function OutThread(x:tmyclass): boolean; stdcall;
type mypointer = function(y:tmyclass): boolean; stdcall;
var
XHandle: Thandle;
frm_p: mypointer;
begin
XHandle := loadlibrary(xxx.dll'); ///////此句运行就错,不用多线程时能通过
if XHandle > 32 then
try
frm_p := GetProcAddress(XHandle, 'OutDataFun');
result := frm_p(x);
finally
freelibrary(XHandle);
end;
end;
function OutData(): boolean;
var
hThread: Thandle;
ThreadID: DWord;begin
result := false;
try
hthread := CreateThread(nil, 0, @OutThread, self, 0, ThreadID);
if hthread = 0 then OutThread(aaa);
finally
if hthread > 0 then closehandle(hthread);
end;
end;
function OutThread(x:tmyclass): boolean; stdcall;
type mypointer = function(y:tmyclass): boolean; stdcall;
var
XHandle: Thandle;
frm_p: mypointer;
begin
XHandle := loadlibrary(xxx.dll'); ///////此句运行就错,不用多线程时能通过
if XHandle > 32 then
try
frm_p := GetProcAddress(XHandle, 'OutDataFun');
result := frm_p(x);
finally
freelibrary(XHandle);
end;
end;
function OutData(): boolean;
var
hThread: Thandle;
ThreadID: DWord;begin
result := false;
try
hthread := CreateThread(nil, 0, @OutThread, self, 0, ThreadID);
if hthread = 0 then OutThread(aaa);
finally
if hthread > 0 then closehandle(hthread);
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货