So I have been working with creating ODBC connections in Inno by utilizing the registry. The issue I have been running into is that Inno does not create all of the keys I set. I am using a 64bit version of Windows and installing a 32 bit application using the 32 bit Inno installer. The path I am using is HKLM\SOFTWARE\WOW6432Node\ODBC\ODBC.INI
Example: I have a connection TESTDBF1 which holds the values: TESTDBF1
This creates the connection in the 32 bit ODBC Administrator but I also need to specify the custom dBase version (IV) and directory (C:\DIR) shown. To accomplish this, the subkeys below must be added, or the ODBC Administrator will only show the default dBase version (V) and current directory.
This Xbase directory is needed to hold the custom settings specified in the main TESTDBF1 section
The keys in the Xbase directory.
In addition, I add the Name: TESTDBF1 as a string "Driver do Microsoft dBase (*.dbf)" into WOW6432Node\ODBC\ODBC.INI\ODBC Data Sources.
To run all of these commands, I created TESTDBF1.reg to confirm functionality.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1]
"Driver"="C:\\WINDOWS\\system32\\odbcjt32.dll"
"DefaultDir"="C:\\IBS"
"DriverId"=dword:00000115
"FIL"="dBase IV;"
"SafeTransactions"=dword:00000000
"UID"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase]
"CollatingSequence"="ASCII"
"Deleted"=hex:00
"ImplicitCommitSync"=""
"PageTimeout"=dword:00000005
"Statistics"=hex:00
"Threads"=dword:00000003
"UserCommitSync"="Yes"
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\ODBC Data Sources]
"TESTDBF1"="Driver do Microsoft dBase (*.dbf)"
Upon merging/running this file, all keys are successfully created and I can confirm the custom values are showing in the ODBC Administrator.
So, I'm thinking - Hey its working! Now I can add into Inno! No. I am using Inno Script Studio as my compiler. I import the registry file TESTDBF1.reg I just used into the script and then run the installer. No such luck. All of the keys at \WOW6432Node\ODBC\ODBC.INI\TESTDBF1 are created but none of the following subdirectories are created (\Engines and \Engines\Xbase) Reminder: Xbase holds the keys that ensure the custom info in ODBC.INI\TESTDBF1 hold when you open the ODBC Administrator.
So after confirming the TESTDBF1.reg works again, I look at the code I am writing in Inno:
; Imported Registry File: "C:\Users\Support\Documents\test\TESTDBF1.reg"
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: string; ValueName: "Driver"; ValueData: "C:\WINDOWS\system32\odbcjt32.dll"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: string; ValueName: "DefaultDir"; ValueData: "C:\DIR"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: dword; ValueName: "DriverId"; ValueData: "$00000115"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: string; ValueName: "FIL"; ValueData: "dBase IV;"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: dword; ValueName: "SafeTransactions"; ValueData: "$00000000"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: string; ValueName: "UID"; ValueData: ""; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: string; ValueName: "CollatingSequence"; ValueData: "ASCII"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: binary; ValueName: "Deleted"; ValueData: "00"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: string; ValueName: "ImplicitCommitSync"; ValueData: ""; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: dword; ValueName: "PageTimeout"; ValueData: "$00000005"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: binary; ValueName: "Statistics"; ValueData: "00"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: dword; ValueName: "Threads"; ValueData: "$00000003"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1\Engines\Xbase; ValueType: string; ValueName: "UserCommitSync"; ValueData: "Yes"; Flags: uninsdeletekey;
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\ODBC Data Sources; ValueType: string; ValueName: "TESTDBF1"; ValueData: "Driver do Microsoft dBase (*.dbf)"; Flags: uninsdeletekey;
Hmm. I can't find anything wrong with that. I ran the install script again and again with different names, directories, and the like and regardless of what I do, I cannot get the \Engines\Xbase keys to write from inside of the install script.
Now, why don't I just run the .reg file at the end of install?
Because part of my script uses the install directory (which changes) as part of these reg keys. Note ValueData. Example:
Root: HKLM; Subkey: SOFTWARE\WOW6432Node\ODBC\ODBC.INI\TESTDBF1; ValueType: string; ValueName: "DefaultDir"; ValueData: "{app}\IBS"; Flags: uninsdeletekey;
After running the installer, this is the key that is created at HKLM\Software\WOW6432Node\ODBC\ODBC.INI\TESTDBF1
Any help would be much appreciated - I am pretty stumped at this point.
I think I figured it out - minutes after posting. The post probably helped get things straight.
So - when writing 32 bit keys, using a 32 bit application and a 32 bit installer, get this - you write to the 64 bit registry directory. You DO NOT write to the WOW6432Node because of whatever back end stuff with Inno. It just doesn't write.
You have to write to the 64 bit directory and somewhere, somehow, Inno and Windows communicate and will automatically take your 32 bit information and place it into the WOW6432Node for you. You just can't do it yourself.
So my actual fix was to change all of my reg entries to HKLM\SOFTWARE\ODBC\ODBC.INI\testdbf1etc and in doing so, everything worked and wrote properly into HKLM\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\testdbf1etc.
I really wish this portion would have been better documented in Inno. If you remember above, my .reg file worked! Inno was the one who wouldn't write the keys properly, but I guess that is to be expected since it is an application instead of referencing the default Windows functions.
Hope this helps the rest of you!