07-20-2004 01:30 PM
07-20-2004 03:17 PM
08-10-2006 10:54 AM - edited 08-10-2006 10:54 AM
I too have had trouble and this appears to be the reason:
If you are using IniFile.c, the problem may be that your SubKey does not exist yet. This causes Ini_ClearRegistry( ) to post an error and Ini_WriteToRegistry( ) doesn't get a chance to call RegCreateKeyEx( ) which is needed in order create your SubKey. (The error returned is -5002, ToolErr_ErrorReadingFile) The workaround is to call RegCreateKeyEx( ) directly to create your SubKey before calling Ini_WriteToRegistry( ). If you're intent on using IniFile.c, then you can hack line at 1452 or (or thereabouts) so that the return from Ini_ClearRegistry( ) doesn't take the error route if the SubKey doesn't exist.
Message Edited by WhiteSalmon on 08-10-2006 11:03 AM
01-05-2012 07:58 AM
After modifying IniFile.c as suggested by WhiteSalmon and including this file in the project, I solved the problem of writing subkeys to the registry that did not previously exist.
In LabWindows/CVI 8.1 the source file is found at "c:\Program Files\National Instruments\CVI81\toolslib\toolbox\inifile.c". The original line at 1452 was replaced so that Ini_WriteToRegistry() continues processing when error -5002 is encountered.
Before:
errChk (Ini_ClearRegistry(hrootKey, baseKeyName));
After:
// Ini_WriteToRegistry() returned -5002 when subkeys did not exist.
error = Ini_ClearRegistry(hrootKey, baseKeyName);
if (error != -5002)
{
errChk(error);
}