Stange text encoding in the Registry for RC1
I've got an application that provides similar functionality to the Device Manager. It displays the devices by "category" similar to the list view in the Device Manager.
It gets the category string from the registry... specifically the "default" string value at each one of the keys like:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11CE-BFC1-08002BE10318}
These string value at these locations used to be just normal unicode text, but with build 5600, the text is a bizarre unicode-wanna be
"[xufkY][?VD/?D-Γ?М ??ινё? !!! ]"
instead of
"DVD/CDROM drives"
It's almost readable as english, so that leads me to believe that the change was deliberate (I can't imagine how you'd achieve this by accident).
So, is this a bug? or some "warning" to not use that registry key value in the future
[924 byte] By [
graye] at [2008-2-15]
Thanks Bill!
Below is the code I've been working with:
using
System;using
System.Collections.Generic;using
System.Text;using
System.Runtime.InteropServices;using
Microsoft.Win32;namespace
ConsoleApplication2{
class Program{
[
DllImport("advapi32.dll")]public static extern int RegOpenKeyEx(IntPtr hKey, string lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);[
DllImport("advapi32.dll")]internal static extern int RegLoadMUIString(IntPtr hKey, string pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint Flags, string pszDirectory);[
DllImport("advapi32.dll")]public static extern int RegCloseKey(IntPtr hKey);static void Main(string[] args){
try{
//NOTE: Testing Vista MUI Registry strings//NOTE: Pointer to HKEYLMIntPtr localMachine = new IntPtr((long)unchecked((int)0x80000002)); //NOTE: regKey will contain the pointer to the open registry keyIntPtr regKey;int pcbData = 0;//NOTE: Open a device key with KEY_READ access rights. RegOpenKeyEx(localMachine,
@"SYSTEM\CurrentControlSet\Control\Class\{36FC9E60-C465-11CF-8056-444553540000}", 0, 0x20019, out regKey);//NOTE: Build the output buffer referenceStringBuilder lptStr = new StringBuilder(1024);//NOTE: ClassDesc contains the MUI formatted stringint returnCode = RegLoadMUIString(regKey, "ClassDesc", lptStr, 1024, out pcbData, 0, null);//NOTE: Close the keyRegCloseKey(regKey);
//NOTE: Output values to consoleConsole.WriteLine("Reg key pointer : " + regKey.ToString());Console.WriteLine("LPTSTR : " + lptStr.ToString());Console.WriteLine("PCBDATA : " + pcbData.ToString());Console.WriteLine("Return Code : " + returnCode.ToString());Console.ReadLine();}
catch (Exception ex){
Console.WriteLine("Exception : " + ex.Message);Console.ReadLine();}
}
}
}
NOTE: I'm getting a 120 return code from this call, and my output buffer (lptStr) is an empty string.
I was told that RegLoadMUIString is not in the RC1 API, can you confirm?
thanks,
-bp