Einzelnen Beitrag anzeigen

Fukiszo
(Gast)

n/a Beiträge
 
#15

AW: Externes Programm Teil 2

  Alt 22. Jan 2018, 20:08
z.B. DLL aus Delphi 7 und nagelneue EXE passen nicht mehr zusammen)
dürfte ich fragen wie das gemeint ist?
Code:
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;
Code:
hier der delphi 7 dll export

exports
  ShowDLL Index 1;
Klappt sowas mit aktuellem Delphi nicht (abgesehen von Unicode, verzeiht das ist falsch ja, bin ja schon beim aufarbeiten, aber der source war noch nicht drann....!)

Geändert von Fukiszo (22. Jan 2018 um 20:19 Uhr) Grund: export angegeben
  Mit Zitat antworten Zitat