Sign in Join
Wiki copytemporary

program Type/de

Zurück zur Seite Code Beispiele.

Dieser Artikel beschäftigt sich mit der Windowsprogrammierung.

Die Funktion prüft, um welchen Programmtyp es sich handelt. Es hängt u. a. vom Programmtyp ab, ob das Betriebssystem das Programm ausführen kann.

pascal
uses
  Windows, ...;

  ...

function funGetEXEType(FileName: string): string;
const
  SCS_32BIT_BINARY = 0;
  SCS_DOS_BINARY = 1;
  SCS_WOW_BINARY = 2;
  SCS_PIF_BINARY = 3;
  SCS_POSIX_BINARY = 4;
  SCS_OS216_BINARY = 5;
  SCS_64BIT_BINARY = 6;

var
  BinaryType: DWORD;

begin

  if GetBinaryType(PChar(FileName), Binarytype) then
    case BinaryType of
      SCS_DOS_BINARY: Result := 'DOS Programm';
      SCS_WOW_BINARY: Result := 'Win16 Programm';
      SCS_32BIT_BINARY: Result := 'Win32 Programm';
      SCS_64BIT_BINARY: Result := 'Win64 Programm';
      SCS_PIF_BINARY: Result := 'PIF Datei';
      SCS_POSIX_BINARY: Result := 'POSIX Programm (Unix)';
      SCS_OS216_BINARY: Result := 'OS/2 16 Bit Programm'
      else
        Result := 'unbekannter Programmtyp'
    end
  else
    Result := 'Die Datei ist kein Programm';

end;

Aufruf der Funktion:

pascal
procedure TForm1.Button1Click(Sender: TObject);
begin

  ...
  
  Form1.Memo1.Lines.Add(funGetEXEType('c:\windows\notepad.exe'));
  
  ...
  
end;

From the Free Pascal wiki, page "program Type/de", as it stood on 2020-02-23 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.