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]
# 1

Good afternoon - Bill Wesse from Microsoft Critical Problem Resolution (CPR) here.

I tend to agree with you concerning the 'on purpose' nature of the default string values. I expect this has everything to do with the Multilingual User Interface (MUI).

Have you checked out 'RegLoadMUIString' (new registry API function for Vista)?

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/regloadmuistring.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/mui_Resource_Shell.asp

Please let me know if this doesn't work for you, and I will dig in deeper!

Regards,

Bill Wesse

BillWesse at 2007-9-3 > top of Msdn Tech,Software Development for Windows Vista,Application Compatibility for Windows Vista...
# 2

Graye,

I am having a similar issue but cannot get the code quite right for the MUI string in the registry. Do you have code working for the RegLoadMUIString P/Invoke call?

-bp

lissbpp at 2007-9-3 > top of Msdn Tech,Software Development for Windows Vista,Application Compatibility for Windows Vista...
# 3

I will start on a util to get/inspect & set - and will dig into the product sources to find out what's up with the format. It is most likely involved with MUI resources (that is, the prefix is most likely marks some language encoding).

Regards,

Bill Wesse

BillWesse at 2007-9-3 > top of Msdn Tech,Software Development for Windows Vista,Application Compatibility for Windows Vista...
# 4

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 HKEYLM

IntPtr localMachine = new IntPtr((long)unchecked((int)0x80000002));

//NOTE: regKey will contain the pointer to the open registry key

IntPtr 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 reference

StringBuilder lptStr = new StringBuilder(1024);

//NOTE: ClassDesc contains the MUI formatted string

int returnCode = RegLoadMUIString(regKey, "ClassDesc", lptStr, 1024, out pcbData, 0, null);

//NOTE: Close the key

RegCloseKey(regKey);

//NOTE: Output values to console

Console.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

lissbpp at 2007-9-3 > top of Msdn Tech,Software Development for Windows Vista,Application Compatibility for Windows Vista...
# 5
It's called pseudo-loc - I think it's used to identify strings that still need to be MUI-ized or something like that. If you can get access to a more recent build, it might be fixed.
DavidTylerHunt at 2007-9-3 > top of Msdn Tech,Software Development for Windows Vista,Application Compatibility for Windows Vista...
# 6

Indeed RC2 has the correct strings in the registry. No need for RegLoadMUIString.

thanks,

-bp

lissbpp at 2007-9-3 > top of Msdn Tech,Software Development for Windows Vista,Application Compatibility for Windows Vista...

Software Development for Windows Vista

Site Classified