LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

regwritestring error

I am trying to make my code, that works well in WindowsXP, work on a Vista 64 machine but I am having issues.  Trying to do an entry into the Registry using RegWriteString(); function on Vista but I keep getting ToolErr_CantOpenKey = -5065.

 

the XP version:

response = RegWriteString(REGKEY_HKLM, "Software\\ODBC\\ODBC.INI\\ODBC Data Sources",
              DB_Source_Name, "Microsoft Access Driver (*.mdb)");

 

the Vista version:

response = RegWriteString(REGKEY_HKLM, "Software\\Wow6432Node\\ODBC\\ODBC.INI\\ODBC Data Sources",
              DB_Source_Name, "Microsoft Access Driver (*.mdb)");

 

I am logged in as adminsitrator...

 

TIA

0 Kudos
Message 1 of 4
(3,809 Views)

Hi TIA,


Running 
char *Message = GetGeneralErrorString(-5065);  
returns the string "Could not open Registry Key".

There could be a number of things that could result in this error. First, it may have to do with running the app as an administrator.

In Windows Vista/7, there is an "Administrator" account as well as "Administrator" Priviledges. Any user can have "Administrator" priviledges, but there is only one Administrator account. Running an app with user Administrator will run the app with Administrator priviledges automatically. Other users need to run the application specifically with Administrator priviledges. You can do this by right-clicking the exe and select "Run as Administrator".

Second, it could be because you are trying to write directly to Wow6432Node. Typically, you would simply write to the registry location without Wow6432Node in the path, and Windows will automatically alias it to the correct location if the application is a 32bit app. In this case, it is a CVI exe, so it will be a 32 bit application.
That means trying to write to Software\\ODBC\\ODBC.INI\\ODBC Data Sources will automatically write to Software\\Wow6432Node\\ODBC\\ODBC.INI\\ODBC Data Sources.

Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 2 of 4
(3,765 Views)
I have tried both ways and I get the same error...-5065 ToolErr_CantOpenKey....
0 Kudos
Message 3 of 4
(3,730 Views)
Sorry forgot to mention using LabWindows CVI SQL Toolkit 2.05... could this be an issue??
0 Kudos
Message 4 of 4
(3,727 Views)