Delphi on 64 bit Windows 7

Some 64 bit Windows notes:

File location:

  • 32 bit programs will be installed on c:\Program Files (x86)\ as 64 bit software will be installed on c:\Program Files\.
  • Likewise, 32 bit system files are installed on c:\Windows\SysWOW64\, while 64 bit files are installed on c:\Windows\System32 – that’s Microsoft contrarian logic for you!
  • Registry keys also are affected so that 32 bit registry items under the HKLM\SOFTWARE key are now installed by Win 7 into HKLM\SOFTWARE\WOW6432Node\ and legacy programs may not know to look for them there (eg. BDEAdmin).
  • 32bit ODBC drivers are set up using 32bit ODBC control panel interface found here: %WINDIR%\SysWOW64\odbcad32.exe
  • 64bit ODBC drivers are set up using the default 64bit ODBC control panel interface found on Control Panel or here: %WINDIR%\System32\odbcad32.exe

32 bit vs 64 bit:

  • all current versions of Delphi are 32 bit, that is, although they can run in 64 bit Win 7, the executables they compile will be 32 bit and thus use 32 bit drivers and dll’s, etc.
  • the forthcoming 64 bit version of Delphi will compile 64 bit executables.
  • if you are looking for your 32bit ODBC drivers, don’t look in the Control Panel – they are the 64bit ones – look instead via c:\Windows\SysWOW64\odbcad32.exe

Help system:

  • Microsoft ceased installing their legacy WinHelp32.exe application in Windows Vista and later.
  • Thus to allow legacy winhelp to function (eg. BDE help), you will to download and install it – see here.

GetVersion:

  • GetVersion in Vista gave a value of 6 unless you choose to run your app in a compatbility mode in which it will return whichever OS version you choose!

MS Virtual PC XP Mode:

  • a neat little functionality in 64bit Win 7 Pro version is the easy ability to create a Win XP virtual machine to run otherwise incompatible legacy software such as old sybase ASE open client drivers, and MS SQL Server 2000.
  • note that this XP mode runs as a separate machine and is updated as usual by Windows Update, and will need its own antiviral software.
  • default RAM allocation is only 512Mb.
  • your Delphi 32 bit apps do run, but I note that I am getting list index out of bounds with one of my apps running in this mode which does not occur on a XP machine nor on 64bit Win 7 itself – as I do not have Delphi installed in my XP mode virtual machine, I have not debugged why this should occur.
  • With the free VMware Player you can convert this Virtual PC VM and use it with the VMware Player which provides better performance than the XP Mode BUT you will need to pay for Windows OS (ie. supply valid Windows license keys) for each VMWare virtual machine.
  • if you install Delphi in a VM, it gives you several benefits. Very easy to backup your development system and you can easily transfer it to another machine. Plus you can avoid component version conflicts between your products or product versions if you use separate VMs. I am yet to do this, does this affect your Delphi and third party component licenses?
  • see here for Jon Aasenden’s blog post on using VM with various versions of Delphi

UAC, Windows Resource Protection and file virtualization issues introduced in 32 bit Vista and later Windows OS including 64 bit Win 7:

  • Changes to HKLM and HKCR registry keys aren’t allowed under these OS versions without admin rights.
  • Make sure you start any installation with administrator-level rights
  • When installing applications designed prior to Vista, and thus not UAC-aware (eg. all Delphi earlier than Delphi 2007, and the BDE), ensure you avoid the default c:\Program Files locations or any other folder path created by the Windows installation!
  • Thus I install Delphi 6 on c:\Delphi6, and Delphi 2007 on c:\Delphi2007.
  • If you run your 32bit compiled Delphi app on a 64bit machine, you will also have to manage these issues, and issues such as sysutils.FileExists(filename) may give a false value for files in certain folders (eg. on another drive on your computer even if user has read/write access), if there are read access issues, or if WOW64 File Virtualization makes you look at a different folder than the one you think you are looking at. One may need to look at temporarily disabling then re-enabling redirection – see here.

Windows 7 date format bug:

  • a known issue with Windows 7 is a bug in date format setting, thus if you use Australian date format, the date format in non-main threads remains as US
  • to fix this, in Control Panel, Regional settings, set date format to a non-US country date format, press Apply, then reset it to your country and press apply.
  • this should fix it for you.
  • alternatively set registry, for example for Australian locale:
      • [HKEY_CURRENT_USER\Control Panel\International]
        “Locale”=”00000C09”
        “LocaleName”=”en-AU”

Borland Database Engine (BDE):

Whilst the BDE is no longer supported with updates ceasing some 8 years ago, it is still useful and works well for Paradox, dBase tables as well as with server databases if used with TClientdatasets. (As nice as DBExpress 4 is, it does not support Paradox, dBase, nor does it seem to support nested SQL statements).

The BDE installed fine using default Delphi 6 installation CD with the BDE default installation will be installed in c:\Program Files (x86)\Common Files\Borland Shared\BDE\.

Alternatively, Do a google search for BDEInfosetup.exe. This will install the BDE on 64-bit Windows, but it does not put the BDEadmin into the control panel. Instead, go to the directory where the BDE is installed – program files (x86)\Borland\Common Files\BDE – and you’ll find BDEadmin.exe.

If you try running BDE Administrator or SQL Explorer and modify an alias and apply edits, the edits will be saved but the app hangs (just as it did for these guys in 64 bit Vista no matter what they tried)

You will need to set security for idapi32.cfg for all users to Modify instead of the default Read only file access, BETTER STILL, move this file away from the c:\Program Files\ folder so that users have read/write access. Ensure BDE Administrator is set to use this new file location by choosing Open Config file, select it then when prompted, Yes to use as default file.

You may also need to go into Options from the BDE Administrator’s Object Menu and check the Win3.1 box which causes everything to be stored in the cfg file rather than the
registry.

Ensure pdoxusrs.net file is on a folder with read/write access for everyone – ie. NOT in c:\ folder!

Now, Delphi may still use the default idapi32.cfg file as installed as it may be looking at the registry to locate it, thus open the registry key and modify it:

HKLM\SOFTWARE\WOW6432Node\Borland\Database Engine\CONFIGFILE01

Setting security for idapi32.cfg and checking the win 3.1 box seems to have resolved the saving alias edits problem for me.

If you install a later version of Delphi after installing an earlier version, remember it will over-write your idapi32.cfg file.

Now, despite all of the above, the Delphi IDE still seems to want to put the BDE PrivateDir as the c:\Windows\System32 folder which of course Delphi cannot write to in Vista and later. This seems to only be an issue when trying to open TQuery components within the IDE with the cachedUpdates = true. You will get an error message such as Do not have permission to write c:\windows\system32\Del2.MB, etc. Set TQuery.CachedUpdates = false and you are in business.

Surely there must be a way to set Delphi’s PrivateDir folder to a read/write folder?

One unresolved issue is the BDE date format – BDE applications seem to default to m/d/y despite the idapi32.cfg and HKLM\SOFTWARE\WOW6432Node\Borland\Database Engine\System\FORMATS\DATE\MODE being set to 1 (which should be d/m/y), even though date settings in Control Panel are set to d/m/yyyy.

A workaround for the date format issue is to call a procedure which sets date format when the application starts – I created a procedure based upon the SetFormatButtonClick code posted here.

Installing BDE manually by just installing BDE registry .reg file will also fail, if like me you have exported a Win XP BDE registry settings and then just install these on a new machine to allow it to use a file server based BDE configuration. Unfortunately, neither 32 bit nor 64 bit Win 7 will allow a simple install of this .reg file even with being logged in as local administrator and UAC turned off.

MS SQL server developer edition:

Delphi 2005 came with MS SQL Server 2000 developer edition, but unfortunately, this will not install on 64 bit Win 7, BUT you can install it on XP Mode Virtual PC on Win 7 if you really had to. (Old versions of Sybase ASE client also will not install in 64 bit Win 7 but will install in XP Mode Virtual PC)

You can download 32 bit MS SQL Server 2008 developer edition from Microsoft and install it, and then just copy your old data files from MS SQL Server 2000 to the equivalent folder in MS SQL Server 2008, and then in the management tools, just “Attach” these data files to run them.

Download and manually install NTWDBLIB.dll to c:\Windows\SysWOW64\ if you need to access MS SQL Server through BDE’s MSSQL driver interface which uses the deprecated DB drivers which are no longer installed in MS SQL Server 2005 and 2008 installations.

Sybase ASE client:

Unfortunately, the Windows XP Sybase msi installation file will fail when attempting to install in either 32 bit or 64 bit Win 7.

Delphi 6:

Although one gets Microsoft’s compatibility warning on installation, my version of Delphi 6 with Infopower 3000 Studio and TeeChart Pro v7.06 installed without major issues and compiles my old apps without obvious problems, although there may be issues with the just-in-time debugger.

I install all my Delphi installations on the c drive directly and avoid the default c:\Program Files locations which will cause user access issues which started with Vista and continues with Win 7, whether 32 bit or 64 bit. If you are using a version of Delphi older than Delphi 2007 on Vista or later, to avoid UAC and file virtualization issues crashing your Delphi then you MUST avoid installing onto a windows created folder!

Thus I install Delphi 6 on c:\Delphi6, and Delphi 2007 on c:\Delphi2007.

Remember Delphi 6 does not have theme support of XP and later – you can add theme support by third party fixes – but then remove these if you upgrade project to Delphi 2007.

You may need to detect if running Vista or later and then add code to manage theme, TTreeView, etc – see Marco Cantu’s CodeRage supplied on D2007 DVDs.

Delphi 2007 and 2009:

Delphi 2007 and 2009 install without obvious issues but apparently requires a HOTFIX to stop the IDE / debugger crashing.

For some reason the global compiler conditional defines were ignored when compiling on 64bit Win 7 when they were active when compiled on 32 bit Win XP. My solution was to create a text file MyDefines.inc and place this in the project folder, and then add {$I MyDefines.inc} after the Unit name of EACH unit that needs those directives. Just use a different MyDefines.inc file in the project folder of other project version (eg. a test vs live project).

Tabsheets display as white in 64bit Win 7, so to avoid this you may need to always have a TPanel or other component on them to keep your GUI more uniform looking.

TTables do not open if Databasename property is blank – for some reason, Delphi 2007 does not use the project folder as default path, instead it looks for System32 folder for the tables – works fine in Delphi 6.

Delphi 2010 and later:

Delphi 2010 and later are designed with Windows 7 in mind and appear to be compatible with Windows 7 64 bit version.

Delphi XE2 now includes a 64 bit Delphi compiler:

According to DavidI in March 2011, most Delphi 32 apps will compile to 64bit without change of code as long as the following (and perhaps other issues) are taken into account:

  • any calls to Windows API must be 64 bit API compatible
  • cannot mix 32 bit and 64 bit code in the same process
  • requires separate 32bit and 64 bit components and libraries
  • no mixing of inline assembler and Pascal in the same block
  • obviously, only the 64bit compiler can use the new 64 bit Win OS extensions and shell extensions
  • some changes to RTL eg. SetWindowLong is replaced with SetWindowLongPtr while pointers passed must e typecast as LONG_PTR not Integer/LongInt
  • SendMessage params should be typecast as WPARAM/LPARAM instead of Integer/LongInt
  • TMessage.result params should be typecast as LRESULT instead of Integer/LongInt
  • SizeOf(Pointer) no longer = 4
  • NativeInt/NativeUInt and pointers to AnsiString are 8 bytes instead of 4 bytes

In the meantime, you are only likely to need a 64 bit Delphi version if:

  • you depend upon 64 bit components or need to interface with 64 bit libraries or code
  • you program in Assembler
  • your app needs access to more RAM than is available in 32 bit paged memory.
No comments yet.

You must be logged in to post a comment.

No trackbacks yet.