Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi statischer DLL-Aufruf bedingt aufrufen (https://www.delphipraxis.net/78551-statischer-dll-aufruf-bedingt-aufrufen.html)

Helmi 6. Okt 2006 20:40


statischer DLL-Aufruf bedingt aufrufen
 
Hallo,

mittels:
Delphi-Quellcode:
function GetFileVersion(const FileName: ShortString): ShortString; stdcall;
  external 'Functions.dll';
ruf ich die Function "GetfileVersion" statisch aus der Function.dll aus.

Ist es möglich zu prüfen, ob die DLL überhaupt vorhanden ist bevor ich diesen statischen Aufruf mache, oder muss geht das nur beim dynamischen Aufruf?

mkinzler 6. Okt 2006 20:49

Re: statischer DLL-Aufruf bedingt aufrufen
 
Das geht nur beim dynamischen Aufruf.

Luckie 6. Okt 2006 20:57

Re: statischer DLL-Aufruf bedingt aufrufen
 
Nein. Wird die Funktion statisch eingebunden, wird beim Linken die DLL in die Importtabelle eingetragen.

Helmi 6. Okt 2006 21:00

Re: statischer DLL-Aufruf bedingt aufrufen
 
oki

Danke!

Das heisst ich muss jetzt nur noch suchen wie man ne dll dynamisch aufruft

mkinzler 6. Okt 2006 21:03

Re: statischer DLL-Aufruf bedingt aufrufen
 
Z.B. LoadLibrary

Luckie 6. Okt 2006 21:06

Re: statischer DLL-Aufruf bedingt aufrufen
 
Delphi-Quellcode:
 type
  TShellexecute = function(hWnd: HWND; Operation, FileName, Parameters,
    Directory: PChar; ShowCmd: Integer): HINST; stdcall;

procedure TForm1.Button1Click(Sender: TObject);
var
  hLib: cardinal;
  MyShellExecute: TShellexecute;
begin
  hLib := LoadLibrary('shell32.dll');
  if hLib <> 0 then
  begin
    @MyShellexecute := GetProcAddress(hLib, 'ShellExecuteA');
    if not Assigned(MyShellexecute) then
    begin
      RaiseLastOSError;
      exit;
    end;
  end
  else
  begin
    RaiseLastOSError;
    exit;
  end;
  MyShellexecute(Form1.Handle, 'open', 'Notepad.exe', nil, nil, SW_NORMAL);
end;

Helmi 6. Okt 2006 21:35

Re: statischer DLL-Aufruf bedingt aufrufen
 
Danke Luckie!!


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz