Well, Hello Again! I'm now using pure C++, too hard But well. I just love how you can manage everything Windows have, is like owning Windows. But well, i have some issues:

extern "C" __declspec(dllexport) char *getValue(char *valueName)
{
	HKEY hKey = HKEY_LOCAL_MACHINE;
	LPCSTR lpSubKey = "SOFTWARE\\Dantom\\BYOND";
	PHKEY phkResult;
	LPDWORD Type;
	LPDWORD bufferSize;
	PVOID returnedData;
	LONG SuccessCreate = RegGetValueA(hKey, lpSubKey, valueName, RRF_RT_ANY, Type, returnedData, bufferSize);
	if(SuccessCreate == ERROR_SUCCESS) {
		RegCloseKey(hKey);
		return returnedData;
	}
}

I'm trying to pass PVOID returnedData; to a char *. Don't ask why, though. You would laught.

Well, i don't know how to pass it. How i do?

EDIT: But yea, i don't know if passing it would fix the things. I meant, we don't have any text to pass, just a pointer. I'm confused...

http://msdn.microsoft.com/en-us/library/ms724868(v=VS.85).aspx

That can not be returned from a dll because memory allocated in a dll can only be destroyed in the DLL, and memory allocated in an application program can only be destroyed in the application program. The two are not compatible. A better way to do it is to add another parameter that is a pointer to the data that is being retrieved, which will be allocated by the calling function, not getData()

It would be the calling functions responsibility to typecast returnData into what ever data type it expects. And that might be difficult if it doesn't know what data type is returned.

extern "C" __declspec(dllexport) BOOL getValue(const char *valueName, void* returnData, size_t returnDataSize)
{
    return RegGetValueA(hKey, lpSubKey, valueName, RRF_RT_ANY, Type, returnData, returnDataSize);
   
}
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.