RegQueryValueEx call is only returning a single character. - Windows CE

This is a discussion on RegQueryValueEx call is only returning a single character. - Windows CE ; Hallo, My problem is that Im trying to query(ATM hopefully move on to copying) reg values but when my query is returned it only displays the first letter of a "string" reg value. I'm sure its something remarkable simple that ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: RegQueryValueEx call is only returning a single character.

  1. RegQueryValueEx call is only returning a single character.

    Hallo,

    My problem is that Im trying to query(ATM hopefully move on to copying)
    reg values but when my query is returned it only displays the first
    letter of a "string" reg value. I'm sure its something remarkable
    simple that im over looking but I can't see it.


    HKEY hkey;
    int hmm = 0;
    rc = RegOpenKeyEx (HKEY_LOCAL_MACHINE,_T("Ident"), 0, KEY_READ, &hkey);
    if (rc == ERROR_SUCCESS)
    {
    fprintf (test,"opened it");
    }
    char* name = (char*)malloc(1024 * sizeof(char));
    DWORD dwDataSize, dwType;
    dwDataSize = sizeof(name);
    dwType = REG_SZ;
    rc = RegQueryValueEx(hkey, _T("Name"), NULL, &dwType, (BYTE *)name,
    &dwDataSize);
    fprintf(test,"char*\n%s\t\t%d\n",name,rc);

    rc = RegQueryValueEx(hkey, _T("Name"), NULL, &dwType, (BYTE *)name,
    &dwDataSize);
    fprintf(test,"BYTE\n%s\t\t%d\n",name,rc);



    opened it
    char*
    C 234
    BYTE
    C 0


    I understand that 234 an exit code meaning there is more data, however
    I'm unclear as how to get to the data. Also if there is more data, why
    then does it exit clean the second time I call it and still only
    retrieve the one char?

    Thanks in advance,
    jimm


  2. Re: RegQueryValueEx call is only returning a single character.

    jimm.sander@gmail.com wrote:
    > char* name = (char*)malloc(1024 * sizeof(char));
    > DWORD dwDataSize, dwType;
    > dwDataSize = sizeof(name);
    > dwType = REG_SZ;
    > rc = RegQueryValueEx(hkey, _T("Name"), NULL, &dwType, (BYTE *)name,
    > &dwDataSize);
    > fprintf(test,"char*\n%s\t\t%d\n",name,rc);


    The values in the registry are stored as wchar_t strings. Do some research
    on the relation between TCHAR, char, wchar_t and _UNICODE. Note that under
    CE, the _UNICODE macro is always defined so code assuming TCHAR=char breaks
    at latest there.

    Uli


  3. Re: RegQueryValueEx call is only returning a single character.

    alright Im at the end of my rope... Ive tried char, TCHAR, wchar_t and
    still cant get more than 1 character returned so I must be doing
    something fundamentally wrong. Ive tried other's code that "always"
    worked for them and still only get a single char returned any clue what
    I might be doing wrong?

    Thanks,
    jimm


    Ulrich Eckhardt wrote:
    > jimm.sander@gmail.com wrote:
    > > char* name = (char*)malloc(1024 * sizeof(char));
    > > DWORD dwDataSize, dwType;
    > > dwDataSize = sizeof(name);
    > > dwType = REG_SZ;
    > > rc = RegQueryValueEx(hkey, _T("Name"), NULL, &dwType, (BYTE *)name,
    > > &dwDataSize);
    > > fprintf(test,"char*\n%s\t\t%d\n",name,rc);

    >
    > The values in the registry are stored as wchar_t strings. Do some research
    > on the relation between TCHAR, char, wchar_t and _UNICODE. Note that under
    > CE, the _UNICODE macro is always defined so code assuming TCHAR=char breaks
    > at latest there.
    >
    > Uli



  4. Re: RegQueryValueEx call is only returning a single character.

    I figureed it out... it is fprintf bursting my bubble.

    Jimm
    jimm.sander@gmail.com wrote:
    > alright Im at the end of my rope... Ive tried char, TCHAR, wchar_t and
    > still cant get more than 1 character returned so I must be doing
    > something fundamentally wrong. Ive tried other's code that "always"
    > worked for them and still only get a single char returned any clue what
    > I might be doing wrong?
    >
    > Thanks,
    > jimm
    >
    >
    > Ulrich Eckhardt wrote:
    > > jimm.sander@gmail.com wrote:
    > > > char* name = (char*)malloc(1024 * sizeof(char));
    > > > DWORD dwDataSize, dwType;
    > > > dwDataSize = sizeof(name);
    > > > dwType = REG_SZ;
    > > > rc = RegQueryValueEx(hkey, _T("Name"), NULL, &dwType, (BYTE *)name,
    > > > &dwDataSize);
    > > > fprintf(test,"char*\n%s\t\t%d\n",name,rc);

    > >
    > > The values in the registry are stored as wchar_t strings. Do some research
    > > on the relation between TCHAR, char, wchar_t and _UNICODE. Note that under
    > > CE, the _UNICODE macro is always defined so code assuming TCHAR=char breaks
    > > at latest there.
    > >
    > > Uli



+ Reply to Thread