Note that there are some explanatory texts on larger screens.

plurals
  1. PORegQueryValueEx() api not providing proper set value on XP
    primarykey
    data
    text
    <p>I am trying to get a value which i had set on registry key "userpath" of type 'REG_SZ'. Simplified version of code is below.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;windows.h&gt; #include &lt;iostream&gt; const static char* SrvKey= "System\\CurrentControlSet\\Services\\LanmanServer\\Parameters"; const static char* sVal = "I am probably \a good boy\0"; const static char* keyName = "userpath"; using namespace std; int main(int argc, char* argv[]){ HKEY hkey; LONG status; DWORD wstatus; DWORD dwCtype; DWORD dwClen; DWORD dwSetStatus; status = RegCreateKeyEx( HKEY_LOCAL_MACHINE, SrvKey, (DWORD) 0, NULL, REG_OPTION_NON_VOLATILE, (KEY_READ | KEY_WRITE), NULL, &amp;hkey, NULL ); if(status != ERROR_SUCCESS){ printf("Error [%d] on creating key handle\n", status); return status; } //RegFlushKey(hkey); dwClen = strlen(sVal); dwCtype = REG_SZ; dwSetStatus = RegSetValueEx(hkey, keyName, 0, dwCtype, (BYTE*)sVal, dwClen); if(dwSetStatus != 0){ printf("\nError in setting value in registry. Error [%d]", dwSetStatus); return dwSetStatus; } RegFlushKey(hkey); DWORD dwCheckType = 0; DWORD dwCheckLen = 0; DWORD dwStatus; dwStatus = RegQueryValueEx( hkey, keyName, NULL, &amp;dwCheckType, NULL, &amp;dwCheckLen); if(dwStatus != 0){ printf("\nError in queering registry for length and type. Error [%d]", dwStatus); return dwStatus; } LPBYTE lpbCheckValue = (LPBYTE) malloc(dwCheckLen); //dwStatus not check at the moment. dwStatus = RegQueryValueEx( hkey, keyName, NULL, &amp;dwCheckType, lpbCheckValue, &amp;dwCheckLen); if(dwStatus != 0){ printf("\nError in queering registry for length and type. Error [%d]", dwStatus); return dwStatus; } printf("queried calue is : [%s]", lpbCheckValue); printf("\n\nEndofProgram\n"); system("PAUSE"); return 0; } </code></pre> <p>I am getting junk value for 'lpbCheckValue' after second RegQueryValueE winapi. Please point me what i am doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload