LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Windows SDK RegGetValue compiles, but program doesn't execute

Solved!
Go to solution

I'm porting software from another library I have that uses Native Windows. After writing a small test program in NI CVI 9.0, I've found that the function RegGetValue() when used, results in a program that won't run (won't even debug, with an error about files not being in the path). Remove that single line and it works so far as it is supposed to.

 

The Programmer's Toolbox in CVI9 has a function to read the registry, but why won't it work with the standard Windows SDK? Is there any way I can get RegGetValue() to work as documented by MSDN within CVI?

 

I've tried including ADVAPI32.LIB and ADVAPI32_LVRT.LIB and neither work (from the lib/MSVC folder)

 

It worries me that the WinSDK is not compatible with CVI and I don't know where I can find such compatibility information.

 

Thanks,

Jason.

0 Kudos
Message 1 of 4
(5,280 Views)
Solution
Accepted by jcurl
Which OS are you running on? According to MSDN, minimum supported OSs are Windows Vista and Windows XP Professional x64 Edition. The same document suggests on Win XP SP2 to use SHRegGetValueinstead. You may look also at RegQueryValueEx instruction.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(5,275 Views)

Hello Jason,

 

I am running on a Vista machine, and had no trouble with the following code:

 

 

#include <windows.h>
#include <ansi_c.h>
#include <utility.h>

int main (int argc, char *argv[])
{
    HKEY     regKey     = {0};
    int      len        = 0;
    int      error      = 0;
    char     *val       = NULL;

    RegOpenKeyEx(HKEY_CURRENT_USER,
                    "Software\\National Instruments\\CVI\\9.0\\FileDialog",
                    0, KEY_READ, &regKey);
    
    RegGetValue(regKey, NULL, "FileDir1", RRF_RT_REG_SZ, NULL, NULL, &len);
    
    val = malloc(sizeof(char)*(len + 1));
    
    if (val != NULL)
    {
        RegGetValue(regKey, NULL, "FileDir1", RRF_RT_REG_SZ, NULL, val, &len);
    }
    
    printf("the value retrieved was %s\n", val);
   
    free(val);
    
    return 0;
}

 

Also, for future reference, the help topic Availability of Interface to Application Programmatic Interface (API) Functions has a listing of all the Win32 API functions that are supported in CVI 9.0.

NickB

National Instruments 

Message Edited by nickb on 03-03-2009 09:46 AM
0 Kudos
Message 3 of 4
(5,261 Views)

Oh my! I do feel tiny - you're right it's not supported on WinXP SP2, but was being ported from something that was running on a Vista box.

 

Then that explains quite nicely why it linked (NI help file mentions the function call in the base package) but why it couldn't be debugged because at load time the reference doesn't exist. Only the error message was a bit confusing.

 

 

0 Kudos
Message 4 of 4
(5,258 Views)