动态调用dll的问题!!!!帮帮我好吗???? (100分)

  • 主题发起人 主题发起人 tank37
  • 开始时间 开始时间
T

tank37

Unregistered / Unconfirmed
GUEST, unregistred user!
我在学习动态调用dll,可是老是出错.....帮帮忙好了:)
type
TInStr = function(Source: PChar
Check: Char): Integer;

procedure TfrmDryDll.Edit2KeyPress(Sender: TObject
var Key: Char);
var
order: Integer;
txt: PChar;
PFunc: TFarProc;
Moudle: THandle;
ch: Char;
begin
ch := Key;
Moudle := Loadlibrary('c:/DryDll.dll');
if Moudle > 32 then
begin
Edit2.Text := '';
Pfunc := GetProcAddress(Moudle, 'TestInStr');
txt := StrAlloc(80);
txt := StrPCopy(txt, Edit1.Text);
Order := TInstr(PFunc)(PChar(Edit1.Text), ch);
if Order = -1 then
Edit3.Text := '不包含这个字符!'
else
Edit3.Text := IntToStr(Order);
end;
Freelibrary(Moudle);
end;
始终查找不到字符,关闭时就出错,请问是怎么回事!
 
type
TInStr = function(Source: PChar
Check: Char): Integer;[blue]stdcall;[/blue]

procedure TfrmDryDll.Edit2KeyPress(Sender: TObject
var Key: Char);
var
order: Integer;
txt: PChar;
PFunc: TFarProc;
Moudle: THandle;
ch: Char;
begin
ch := Key;
Moudle := Loadlibrary('c:/DryDll.dll');
if Moudle > 32 then
begin
Edit2.Text := '';
Pfunc := GetProcAddress(Moudle, 'TestInStr');
txt := StrAlloc(80);
txt := StrPCopy(txt, Edit1.Text);
Order := TInstr(PFunc)(PChar(Edit1.Text), ch);
if Order = -1 then
Edit3.Text := '不包含这个字符!'
else
Edit3.Text := IntToStr(Order);
end;
Freelibrary(Moudle);
end;
 
后退
顶部