Delphi Skyline
یک شنبه 24 شهریور 1387, 00:39 صبح
تابع زیر نام DLL و نام تابع مورد نظر را گرفته و اجرا می کند ولی تابعی که قصد فراخوانی داریم یک پارامتر از نوع عدد صحیح دارد . هنگام کامپایل کد زیر کامپایلر خطای داخلی را گوش زد می کند . تنها در صورتی که یک عدد به ورودی تابع داده شود کامپایل می شود وگرنه اگر متغیر باشد خطا می دهد . می خواستم ببینم مشکل از کجاست . با تشکر .
function LoadAndRunDLLProcedure(
sDLL,
sFunc : string )
: boolean;
type
// define the type of "function"
// we're calling
TFunc_Start = procedure(i : integer);
var
Func_Start : TFunc_Start;
ss : integer;
hDll : THandle;
FuncPtr : TFarProc;
sMsg : string;
begin
Result := False;
hDll := LoadLibrary(
PChar( sDLL ) );
if(hDll > 32)then
begin
FuncPtr :=
GetProcAddress(
hDll, PChar( sFunc ) );
@Func_Start := FuncPtr;
if(nil <> @Func_Start)then
begin
//ss := -;
Func_Start(ss);
Result := True;
end else
begin
sMsg := 'DLL entry point ' +
sFunc + ' not found';
MessageBox(
0, PChar( sMsg ), 'Error',
MB_OK );
end;
FreeLibrary( hDll );
end else
begin
sMsg := 'File ' + sDLL +
' not found';
MessageBox(
0, PChar( sMsg ), 'Error',
MB_OK );
end;
end;
function LoadAndRunDLLProcedure(
sDLL,
sFunc : string )
: boolean;
type
// define the type of "function"
// we're calling
TFunc_Start = procedure(i : integer);
var
Func_Start : TFunc_Start;
ss : integer;
hDll : THandle;
FuncPtr : TFarProc;
sMsg : string;
begin
Result := False;
hDll := LoadLibrary(
PChar( sDLL ) );
if(hDll > 32)then
begin
FuncPtr :=
GetProcAddress(
hDll, PChar( sFunc ) );
@Func_Start := FuncPtr;
if(nil <> @Func_Start)then
begin
//ss := -;
Func_Start(ss);
Result := True;
end else
begin
sMsg := 'DLL entry point ' +
sFunc + ' not found';
MessageBox(
0, PChar( sMsg ), 'Error',
MB_OK );
end;
FreeLibrary( hDll );
end else
begin
sMsg := 'File ' + sDLL +
' not found';
MessageBox(
0, PChar( sMsg ), 'Error',
MB_OK );
end;
end;