This compiles in 32 Bit, but not in 64 Bit.
Must I declare "MessageRes" as Windows.DWORD_PTR or must I pass "MessageRes" as "@MessageRes"? Both compiles in 64 Bit.
I use FPC331 (Trunk) on Windows 64 Bit.
How must I test "CompilerVersion" to get this reliably going in FPC 3.3.1 64 Bit and 32 Bit?
The code snippet is taken from a Sourceforge project "path manager" that was last updated in 2013.
https://sourceforge.net/projects/pathtool/There is a 32 bit binary exe included that works without problems, but I want to add functionality (automatic Backup of environment variables before and after)
The $IF, $IFDEF conditions marked with "// -> No" are not active, I indented them for clarity, for these the $ELSE branch is active.
procedure EnvInformation.RefreshEnvironment(const Timeout: Cardinal = 5000);
var
{$IFDEF CONDITIONALEXPRESSIONS} //->No
{$IF CompilerVersion >= 23.0} // Delphi XE2
MessageRes: Windows.DWORD_PTR;
{$ELSE}
MessageRes: Windows.DWORD;
{$IFEND}
{$ELSE}
MessageRes: Windows.DWORD;
{$ENDIF}
begin
Windows.SendMessageTimeout(
Windows.HWND_BROADCAST,
Messages.WM_SETTINGCHANGE,
0,
LPARAM(PChar('Environment')),
Windows.SMTO_ABORTIFHUNG, Timeout,
{$IFDEF CONDITIONALEXPRESSIONS} //->No
{$IF CompilerVersion >= 23.0} // Delphi XE2 //-No
@MessageRes
{$ELSE}
MessageRes
{$IFEND}
{$ELSE}
MessageRes // -> Compiles in 32 Bit, but not in 64 Bit
{$ENDIF}
);
end;