LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

use Win32 API in LabWindows/CVI

Hi!  LabWindows/CVI Engineer !
I need your help!
I'm trying to access win.ini file with Win32 API. As you know, GetProfileString and GetProfileStringEx function allow to access win.ini file.
WriteProfileString function is working well and i check text with notepad s/w.
But i can't access data with win32 api(GetProfileString, GetProfileStringEx).
When i checked with debugging, i found  all zero string. i will atach sample source.
and i try to access registry.
but registry access function isn't working neither.

I'm wating your quick response.
 
 
OS : WinXP SP2
LabWindows/CVI : 8.1.0
Compile Option : default
 
void GetProfile(void)
{
        DWORD  lRetValue = 0,lRet=0;
        char szTmp[1024];
        memset(szTmp,0,sizeof(szTmp));
        lRet = GetProfileString("Test","Item1","Not Define",szTmp,lRetValue); // No Return data (All zero)
        SetCtrlVal(panelHandle,PANEL_STRING_READ,szTmp);
}
 
void WriteProfile(void)
{
        char szTmp[1024];
        DWORD   lRet = 0;
        memset(szTmp,0,sizeof(szTmp));
        GetCtrlVal(panelHandle,PANEL_STRING_WRITE,szTmp);
        lRet = WriteProfileString("Test","Item1",szTmp); // Ok write to win.ini file
 }
 
void GetRegisty(char *pszCompany)
{
        u32  lRetValue = 0,lRet=0;
        char szTmp[1024];
        HKEY hApp = NULL;
        DWORD lType = REG_SZ;
       memset(szTmp,0,sizeof(szTmp));
        if(RegOpenKeyEx(HKEY_CURRENT_USER,"Software\\Application\\Name",0,KEY_ALL_ACCESS,&hApp)
                != ERROR_SUCCESS)
                return;
        lRetValue = 0;
        lRet = RegQueryValueEx(hApp,"Company",NULL,
                &lType,(LPBYTE)pszCompany,&lRetValue);
        if(hApp != NULL)
                RegCloseKey(hApp);
}
0 Kudos
Message 1 of 3
(3,829 Views)

hi Baems,

 if you only want to write and read ini file , you  can load inifile.fp (toolslib\toolbox\inifile.fp ), it's easy to do it .

for  Win32 API , do you install SDK when you install CVI?

 

Sonic

Sonic

Diffrent Strokes for Different Folks
0 Kudos
Message 2 of 3
(3,824 Views)
The last parameter needs to be the size of the buffer you are passing (e.g. sizeof(szTmp)). You are passing IRetValue, which you initialize to 0. By doing this, you're telling the function that szTmp can hold 0 bytes, so the function copies nothing into it.

Mert A.
National Instruments
0 Kudos
Message 3 of 3
(3,802 Views)