mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Introduce 64bit builds and 32/64 bit mixed installer
This commit is contained in:
@ -320,6 +320,7 @@ type
|
||||
function GetOutputFilenamePlaceholders: TStringList;
|
||||
function GetSystemImageList: TImageList;
|
||||
function GetSystemImageIndex(Filename: String): Integer;
|
||||
function GetExecutableBits: Byte;
|
||||
|
||||
|
||||
var
|
||||
@ -2631,6 +2632,45 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function GetExecutableBits: Byte;
|
||||
const
|
||||
kb32 = 1024 * 32;
|
||||
var
|
||||
ExeFilename: String;
|
||||
Buffer: Array[0..kb32-1] of Byte; // warning: assuming both headers are in there!
|
||||
hFile: DWord;
|
||||
bRead: DWord;
|
||||
bToRead: DWord;
|
||||
pDos: PImageDosHeader;
|
||||
pNt: PImageNtHeaders;
|
||||
begin
|
||||
Result := 32;
|
||||
ExeFilename := ParamStr(0);
|
||||
hFile := CreateFile(pChar(ExeFilename), GENERIC_READ, FILE_SHARE_READ, NIL, OPEN_EXISTING, 0, 0);
|
||||
if hFile <> INVALID_HANDLE_VALUE then try
|
||||
bToRead := GetFileSize(hFile, NIL);
|
||||
if bToRead > kb32 then
|
||||
bToRead := kb32;
|
||||
if not ReadFile(hFile, Buffer, bToRead, bRead, NIL) then
|
||||
Exit;
|
||||
if bRead = bToRead then begin
|
||||
pDos := @Buffer[0];
|
||||
if pDos.e_magic = IMAGE_DOS_SIGNATURE then begin
|
||||
pNt := PImageNtHeaders(LongInt(pDos) + pDos._lfanew);
|
||||
if pNt.Signature = IMAGE_NT_SIGNATURE then begin
|
||||
if pNt.FileHeader.Machine and IMAGE_FILE_32BIT_MACHINE > 0 then
|
||||
Result := 32
|
||||
else
|
||||
Result := 64
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
CloseHandle(hFile);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user