Using variants and Int64 values under Windows 2000 can cause problems.

Abstract: Using variants and Int64 values under Windows 2000 can cause problems.
  • Product Name: Delphi
  • Product Version: 2006
  • Product Component: Compiler
  • Platform/OS Version: Win32

The reason for seeing issues with variants with the variant type varInt64 on Windows 2000 (Win2k) is because Win2k just does not support the type.

To see the issue execute the following code on Win2k:

procedure TForm1.Button2Click(Sender: TObject);


v,v2: OleVariant;

i: Int64;


I := 123456789012345;

v := i;

v2 := 'Y';

v := v2; // <- Error happens during a call to the _VarCopy which calls VariantCopy in OLEAUTO32.DLL


The RTL have a facility to workaround the issue to some extent.

from the Variants.pas source file...

// If TRUE Int64 values are converted to varDouble for compatibility with

// Windows 9x/2000 platforms which don't support varInt64 in OleVariant.

OleVariantInt64AsDouble: Boolean = False;

The following unit can be used set the above variable on Win2k


unit VariantOSSetup;




Sysutils, Variants;

function CheckWin32VersionBelow(AMajor: Integer; AMinor: Integer = 0): Boolean;


Result := (Win32MajorVersion < AMajor) or ((Win32MajorVersion = AMajor) and

�����������������(Win32MinorVersion <= AMinor));



OleVariantInt64AsDouble := CheckWin32VersionBelow(5);



As you will notice you will lose significant digits.

Published on: 4/15/2007 7:10:33 PM

Server Response from: ETNASC03

Copyright© 1994 - 2013 Embarcadero Technologies, Inc. All rights reserved.