Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Saber si un programa esta hecho en Delphi (https://www.clubdelphi.com/foros/showthread.php?t=80446)

seoane 08-06-2006 16:49:52

Saber si un programa esta hecho en Delphi
 
A veces podemos tener curiosidad por saber si un programa esta echo en Delphi, para eso podemos utilizar una marca que deja el compilador en el TimeStamp del ejecutable.

Código Delphi [-]
function HechoEnDelphi(Filename: string): Boolean;
const
  BorlandMagicTimeStamp = $2A425E19;
var
  hFile: THandle;
  BytesRead: DWORD;
  ImageDosHeader: TImageDosHeader;
  ImageNtHeaders: TImageNtHeaders;
begin
  Result := FALSE;
  hFile := CreateFile(PChar(Filename), GENERIC_READ, FILE_SHARE_READ, nil,
    OPEN_EXISTING, 0, 0);
  if (hFile <> INVALID_HANDLE_VALUE) then
  begin
    if ReadFile(hFile, ImageDosHeader, SizeOf(TImageDosHeader),BytesRead, nil) then
      if BytesRead = SizeOf(TImageDosHeader) then
        if ImageDosHeader.e_magic = IMAGE_DOS_SIGNATURE then
          if SetFilePointer(hFile, ImageDosHeader._lfanew, nil, FILE_BEGIN) <> $FFFFFFFF then
            if ReadFile(hFile, ImageNtHeaders, SizeOf(TImageNtHeaders), BytesRead, nil) then
              if BytesRead = SizeOf(TImageNtHeaders) then
                if ImageNtHeaders.Signature = IMAGE_NT_SIGNATURE then
                  Result:= ImageNtHeaders.FileHeader.TimeDateStamp = BorlandMagicTimeStamp;
    CloseHandle(hFile);
  end;
end;

Ejemplo de uso:
Código Delphi [-]
  // Vamos a comprobar nuestro propio programa
  if HechoEnDelphi(ParamStr(0)) then
    ShowMessage('Sorpresa, estoy hecho en delphi !!!');


La franja horaria es GMT +2. Ahora son las 02:18:45.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi