Thema: Delphi DLL Problem

Einzelnen Beitrag anzeigen

JnZn558

Registriert seit: 22. Aug 2004
98 Beiträge
 
#1

DLL Problem

  Alt 15. Aug 2010, 00:57
my dll hier
Delphi-Quellcode:
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.
my prog, das die funktion aufruft
Items[ i ].SubItems.Add( GetPathFromProcID( PE32[ i ].th32ProcessID ) ); 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.

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
Peace on the world

Geändert von JnZn558 (15. Aug 2010 um 11:37 Uhr)
  Mit Zitat antworten Zitat