Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
Delphi 10.4 Sydney
|
AW: Vom Record gehen teile verloren
14. Jul 2021, 15:43
Zum Drüber nachdenken:
Was passiert mit dem HWND $112233445566 unter 64-Bit, wenn du es in eine Variable vom Typ LongInt steckst?
Delphi-Quellcode:
program Project6;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Winapi.Windows,
Winapi.Messages,
System.Classes;
type
TDummy = class
procedure WndProc( var Message: TMessage);
end;
var
LDummy: TDummy;
LHandle: HWND;
LLong_Ptr: LONG_PTR;
LLongInt: LongInt;
{ TDummy }
procedure TDummy.WndProc( var Message: TMessage);
begin
end;
begin
try
Writeln(' Size of a HWND: ', SizeOf(HWND), ' bytes!', ' Min: ', Low(HWND), ' High: ', High(HWND));
Writeln(' Size of a LONG_PTR: ', SizeOf(LONG_PTR), ' bytes!', ' Min: ', Low(LONG_PTR), ' High: ', High(LONG_PTR));
Writeln(' Size of a LongInt: ', SizeOf(LongInt), ' bytes!', ' Min: ', Low(LongInt), ' High: ', High(LongInt));
LDummy := TDummy.Create;
try
LHandle := AllocateHWnd(LDummy.WndProc);
Writeln(' HWND: ', UINT_PTR(LHandle).ToHexString);
LLong_Ptr := LHandle;
Writeln(' LONG_PTR: ', LLong_Ptr.ToHexString);
LLongInt := LHandle;
Writeln(' LongInt: ', LLongInt.ToHexString);
finally
DeallocateHWnd(LHandle);
LDummy.Free;
end;
except
on E: Exception do
Writeln(E.ClassName, ' : ', E. Message);
end;
Readln;
end.
|
|
Zitat
|