Function LinkAPI(Const Module, FunctionName: String; ShowError: Boolean): Pointer; StdCall;
var
hLib: HMODULE;
begin
Result := NIL;
try
hLib := GetModuleHandle(PChar(Module));
if hLib = 0 then
hLib := LoadLibrary(PChar(Module));
if hLib <> 0 then
Result := GetProcAddress(hLib, PChar(FunctionName))
else
Result := NIL;
if ((Result = NIL) and (ShowError)) then
raise
Exception.Create('Unable'+' '+'to'+' '+'Load'+' '+ExtractFileName(Module));
except
Result := NIL;
if (ShowError) then
raise
Exception.Create('Unable'+' '+'to'+' '+'Load'+' '+ExtractFileName(Module));
end;
end;
procedure TTASKFORM.ModsMenu2Click(Sender: TObject);
var
i : Integer;
begin
if (LB_Mods.ItemIndex <> -1) then
begin // start
if not Assigned(_LoadPlugin) then @_LoadPlugin := LinkAPI(PChar(ChangeFileExt(Application.ExeName, '.dll')),'LoadPlugin', TRUE);
if Assigned(_LoadPlugin) then
begin
try
if SetEnvironmentVariable(PChar(ChangeFileExt(ExtractFileName(ParamStr(0)), '')), pChar(GetFileName(LB_Mods.Items[LB_Mods.ItemIndex]))) then
if GetEnvironmentVariable(PChar(ChangeFileExt(ExtractFileName(ParamStr(0)), ''))) <> '' then
begin
Application.NormalizeAllTopMosts;
i := _LoadPlugin(2);
Application.RestoreTopMosts;
end;
except
Application.RestoreTopMosts;
end;
end;
end; // start
end;