installationodbcdsnregeditinstallshield-2012

how to install 64-bit odbc by installshield in setup.rul?


//install 32-bit odbc dsn 
szFilePath="\\SOFTWARE\\Wow6432Node\\ODBC\\ODBC.INI\\"^szDemoDB;
RegDBSetKeyValueEx(szFilePath,"Database",REGDB_STRING, szDemoDB,-1); 
RegDBSetKeyValueEx(szFilePath,"Driver",REGDB_STRING, "c:\Windows\SysWOW64\sqlncli11.dll",-1);
RegDBSetKeyValueEx(szFilePath,"Server",REGDB_STRING,"(localdb)\\.\\v11.0",-1);
szFilePath="\\SOFTWARE\\Wow6432Node\\ODBC\\ODBC.INI\\ODBC Data Sources";
RegDBSetKeyValueEx(szFilePath,szDemoDB,REGDB_STRING, "SQL Server Native Client 11.0",-1);
//install 64-bit odbc dsn 
szFilePath="\\SOFTWARE\\ODBC\\ODBC.INI\\"^szDemoDB;
RegDBSetKeyValueEx(szFilePath,"Database",REGDB_STRING, szDemoDB,-1); 
RegDBSetKeyValueEx(szFilePath,"Driver",REGDB_STRING, "c:\Windows\System32\sqlncli11.dll",-1); 
RegDBSetKeyValueEx(szFilePath,"Server",REGDB_STRING,"(localdb)\\.\\v11.0",-1);
szFilePath="\\SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources";
RegDBSetKeyValueEx(szFilePath,szDemoDB,REGDB_STRING, "SQL Server Native Client 11.0",-1);

This is part code in Setup.rul. The top half is install 32-bit odbc dsn. It works well. I can see and use my 32-bit datasource in regedit.

The second half doesn't work. It confused me, I found the path \\SOFTWARE\\ODBC\\ODBC.INI\\ is invalid,the RegDBSetKeyValueEx always set value to path \\SOFTWARE\\Wow6432Node\\ODBC\\ODBC.INI\\


Solution

  • REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;
    
    szFilePath="\\SOFTWARE\\ODBC\\ODBC.INI\\"^szDemoDB;
    RegDBSetKeyValueEx(szFilePath,"Database",REGDB_STRING, szDemoDB,-1); 
    RegDBSetKeyValueEx(szFilePath,"Driver",REGDB_STRING, "c:\Windows\System32\sqlncli11.dll",-1); 
    RegDBSetKeyValueEx(szFilePath,"Server",REGDB_STRING,"(localdb)\\.\\v11.0",-1);
    szFilePath="\\SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources";
    RegDBSetKeyValueEx(szFilePath,szDemoDB,REGDB_STRING, "SQL Server Native Client 11.0",-1);
    
    REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY;