Quote Originally Posted by Simoninman View Post
This is my function:
Code:
WCHAR* WMIQuery(char* QueryName, char* ClassName, char* PropertyName, char* QueryArgument)
{
	WCHAR* QueryResult;
	...
	return QueryResult;
}
You return a pointer to WCHAR that is defined locally within the WMIQuery() function.
But it goes out of scope just before this function returns, so the return value points to some garbage!

Either return CString (or std::wstring) objects or add additional parameter (WCHAR* QueryResult) in the argument list of the function.