naderanhari
سه شنبه 06 اردیبهشت 1390, 17:44 عصر
میخوام کتابخانه ارسال پیام کوتاه رو بارگذاری کنم ولی نمیدونم چرا بارگذاری نمیشه؟! مشکل از چی میتونه باشه؟
ویندوز 7، دلفی 2009، فایل dll رو تو system , system32 و کنار فایل exe هم کپی کردم. ولی بازم لود نمیشه.
پیغام DllName + ' library not found' رو نشون میده. یعنی مقدار Handle رو صفر قرار داده.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
type
TConnect = function (): Integer; stdcall;
const
DllName = 'mssoap1.dll';
procedure TForm2.Button1Click(Sender: TObject);
var
Handle: THandle;
FPointer: TFarProc;
MyConnect: TConnect;
MyCode: Integer;
begin
Handle := SafeLoadLibrary (DllName);
if (Handle > 0) then
try
FPointer := GetProcAddress (Handle, PChar ('Connect'));
if FPointer <> nil then
begin
MyConnect := TConnect (FPointer);
MyCode := MyConnect();
ShowMessage( InttoStr(MyCode));
end
else
ShowMessage ('Connect' + ' DLL function not found');
finally
FreeLibrary (Handle);
end
else
ShowMessage (DllName + ' library not found');
end;
end.
ویندوز 7، دلفی 2009، فایل dll رو تو system , system32 و کنار فایل exe هم کپی کردم. ولی بازم لود نمیشه.
پیغام DllName + ' library not found' رو نشون میده. یعنی مقدار Handle رو صفر قرار داده.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
type
TConnect = function (): Integer; stdcall;
const
DllName = 'mssoap1.dll';
procedure TForm2.Button1Click(Sender: TObject);
var
Handle: THandle;
FPointer: TFarProc;
MyConnect: TConnect;
MyCode: Integer;
begin
Handle := SafeLoadLibrary (DllName);
if (Handle > 0) then
try
FPointer := GetProcAddress (Handle, PChar ('Connect'));
if FPointer <> nil then
begin
MyConnect := TConnect (FPointer);
MyCode := MyConnect();
ShowMessage( InttoStr(MyCode));
end
else
ShowMessage ('Connect' + ' DLL function not found');
finally
FreeLibrary (Handle);
end
else
ShowMessage (DllName + ' library not found');
end;
end.