![]() |
DLL Problem
my dll hier
Delphi-Quellcode:
my prog, das die funktion aufruft
library ProcessLib;
uses SysUtils, Windows, TlHelp32{, PsAPI}; //{$R *.res} function QueryFullProcessImageName( hProcess: THandle; dwFlags: DWORD; lpExeName: PChar; nSize: PDWORD ): BOOL; stdcall; external kernel32 name 'QueryFullProcessImageName' + {$IFDEF UNICODE} 'W' {$ELSE} 'A' {$ENDIF}; function GetPathFromProcID( dwProcID: Cardinal ): string; var hProcess: THandle; nLen: Cardinal; szPath: array[ 0..MAX_PATH ] of Char; begin FillChar( szPath, MAX_PATH, 0 ); hProcess := OpenProcess( PROCESS_QUERY_INFORMATION, False, dwProcID ); Result := ''; if hProcess <> 0 then begin // das ist 32 bit funktion //dwRet := GetModuleFileNameEx( hProcess, 0, szPath, MAX_PATH ); //if dwRet = ERROR_PARTIAL_COPY then // das geht auch unter 64 bit //GetProcessImageFileName( hProcess, szPath, MAX_PATH ); nLen := MAX_PATH; if QueryFullProcessImageName( hProcess, 0, szPath, @nLen ) then Result := string( szPath ) ; end; CloseHandle( hProcess ); end; exports GetPathFromProcID; begin end.
Delphi-Quellcode:
nach aufruf dieser funktion in meinem prog, laeuft zwar gut, aber es wird nicht richtig beendet. d.h. ich muss es in delphi program reset klicken um es richtig zu beenden.
Items[ i ].SubItems.Add( GetPathFromProcID( PE32[ i ].th32ProcessID ) );
ausserdem tritt ein exception auf.
Code:
Debugger Fault Notification
prog.exe raised too many consecutive exceptions. access violation at 0x000214bd: write of address 0x01eb3b84. process stopped. use step or run to continue |
AW: weiss net wo der fehler liegt
Hallo JnZn558,
das sieht nach dem typischen Fehler aus, wenn Du kein ShareMem verwendest bei DLL-Routinen mit Strings als Parameter. Die unit ShareMem muß als erste eingebunden werden in der library/dll UND im Prgramm/exe. Oder Du stellst von string auf z.B. PChar um. Grüße blauweiss |
AW: weiss net wo der fehler liegt
Hi JnZn558,
bitte gib deinem Thread einen aussagekräftigen Titel, der es ermöglicht zu erkennen, worum es geht. Danke! Liebe Grüße, Frederic |
AW: weiss net wo der fehler liegt
Zitat:
|
AW: DLL Problem
Schon versucht: nLen-1 ?
Delphi-Quellcode:
if QueryFullProcessImageName( hProcess, 0, szPath, nLen-1 ) then
Result := string( szPath ) ; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:12 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