Anyone got any pointers on the interpretation of REG_BINARY data such as the ascii strings that are stored as binary values in

HKEY_CURRENT_USER "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs\\folder";

I have long mastered most of the Win32 Registry functions but never really had the need to delve into the murky depths of binary. I guess that it must be the same for most, as there is presious little on the web and nothing at all from a win32 perspective.

cheers

robtech

Read the binary data into a buffer.

If the first 10 bytes pass 'isprint' (in ctype), then it might be a printable string
If every other byte passes 'isprint', and the other alternate bytes are zero, then it might be a unicode string.

In any event, you know what the data is (a filename), so try passing it to the usual win32 file functions.

Thanks for your interest Salem, it is very much appreciated.
I still can't get things to work. Here's a snippet of source.
FindFirstFile() is the first win32 file function that came to mind.

I'm still convinced that a conversion mechanism is needed before
you can use the LPBYTE buffer for any sort of string. You say pass it to the usual win32 file functions, but you don't say in what form. I can manage digital to integer simply by (BYTE *) &i, but I can't produce a string and all of the win32 file functions take character
string input.

unsigned char rgbuf[4096] = {'\0'}; 
unsigned long dwsiz = sizeof(rgbuf);
RegQueryValueEx(hKey, LPTSTR(achValue), 0, NULL, rgbuf, &dwsiz);
//achValue is in the form of the lpValueName from enumerating with RegEnumValue()
//up until this point I can confirm that the rgbuf contains a binary string value

WIN32_FIND_DATA fff;
 
FindFirstFile(rgbuf,&fff);

SendMessage(list1,(UINT)LB_INSERTSTRING,(WPARAM)-1,(LPARAM)fff.cFileName);               

delete(&fff);

What was the question?

You seem to read the registry OK, but the file read seems totally unrelated to that.

Before you go on a casting frenzy, make sure you know whether you're using the ASCII interface or the UNICODE interface to win32 (the latter is preferred if you have a reasonably up to date compiler).

And the delete() call is just plain wrong.

I was your suggestion that I used a win32 file function in this position.
It was typed quickly and off the top of my head so the "delete(&fff)"
was a mistake that perhaps I should have taken the time to see,
then again, so is begining a sentence with the word "And".

Thanks for your time but I think that I'll look elsewhere for the answer
to this one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.