473,786 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RegLoadMUIStrin g Vista P-Invoke

Hello,
I'm trying to get an MUI string out of the registry in display friendly
format. From what I've read, strings in the following format:
“@[path]\dllname,-strID” are MUI strings and receive special handling via
the RegLoadMUIStrin g API call.

This is what I have come up with for the call:
[DllImport("adva pi32.dll")]
internal static extern long RegLoadMUIStrin g(IntPtr hKey, string pszValue,
StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint Flags, string
pszDirectory);

I'm calling this function with a valid pointer to an open registry key,
passing in the appropriate value key (pszValue) which has the MUI formatted
string. When I check the output buffer (pszOutBuf) it's always an empty
string.

Has anyone been able to get this call to work? I cannot find any examples
on the web.

thanks,
-bp

Oct 9 '06 #1
10 2463
Below is full code:
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using Microsoft.Win32 ;

namespace ConsoleApplicat ion2
{
class Program
{
[DllImport("adva pi32.dll")]
public static extern long RegOpenKeyEx(In tPtr hKey, string
lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);

[DllImport("adva pi32.dll")]
internal static extern long RegLoadMUIStrin g(IntPtr hKey, string
pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint Flags,
string pszDirectory);

[DllImport("adva pi32.dll")]
public static extern int RegCloseKey(Int Ptr hKey);
static void Main(string[] args)
{
try
{
//NOTE: Testing Vista MUI Registry strings

//NOTE: Pointer to HKEYLM
IntPtr localMachine = new
IntPtr((long)un checked((int)0x 80000002));

//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(lo calMachine,
@"SYSTEM\Curren tControlSet\Con trol\Class\{36F C9E60-C465-11CF-8056-444553540000}", 0, 0x20019, out regKey);

//NOTE: Build the output buffer reference
StringBuilder lptStr = new StringBuilder(1 024);

//NOTE: ClassDesc contains the MUI formatted string
RegLoadMUIStrin g(regKey, "ClassDesc" , lptStr, 1024, out
pcbData, 0, null);

//NOTE: Close the key
RegCloseKey(reg Key);

//NOTE: Output values to console
Console.WriteLi ne("Reg key : " + regKey.ToString ());
Console.WriteLi ne("LPTSTR : " + lptStr.ToString ());
Console.WriteLi ne("PCBDATA : " + pcbData.ToStrin g());
Console.ReadLin e();
}
catch (Exception ex)
{
Console.WriteLi ne("Exception : " + ex.Message);
Console.ReadLin e();
}
}
}
}
"lissbpp" wrote:
Hello,
I'm trying to get an MUI string out of the registry in display friendly
format. From what I've read, strings in the following format:
“@[path]\dllname,-strID” are MUI strings and receive special handling via
the RegLoadMUIStrin g API call.

This is what I have come up with for the call:
[DllImport("adva pi32.dll")]
internal static extern long RegLoadMUIStrin g(IntPtr hKey, string pszValue,
StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint Flags, string
pszDirectory);

I'm calling this function with a valid pointer to an open registry key,
passing in the appropriate value key (pszValue) which has the MUI formatted
string. When I check the output buffer (pszOutBuf) it's always an empty
string.

Has anyone been able to get this call to work? I cannot find any examples
on the web.

thanks,
-bp
Oct 9 '06 #2
[DllImport("adva pi32.dll")]
public static extern long RegOpenKeyEx(In tPtr hKey, string
lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);

[DllImport("adva pi32.dll")]
internal static extern long RegLoadMUIStrin g(IntPtr hKey, string
pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint Flags,
string pszDirectory);
The return type for both functions should be int, not long.
Mattias

--
Mattias Sjgren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 9 '06 #3
Changing the return types to int had no affect on the outcome of the call.

-brett

"Mattias Sjögren" wrote:
[DllImport("adva pi32.dll")]
public static extern long RegOpenKeyEx(In tPtr hKey, string
lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);

[DllImport("adva pi32.dll")]
internal static extern long RegLoadMUIStrin g(IntPtr hKey, string
pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint Flags,
string pszDirectory);

The return type for both functions should be int, not long.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 9 '06 #4
And what does RegLoadMUIStrin g call return? You don't check the return value
in your code!!!

Willy.
"lissbpp" <li*****@discus sions.microsoft .comwrote in message
news:8F******** *************** ***********@mic rosoft.com...
| Changing the return types to int had no affect on the outcome of the call.
|
| -brett
|
| "Mattias Sjögren" wrote:
|
| [DllImport("adva pi32.dll")]
| public static extern long RegOpenKeyEx(In tPtr hKey, string
| lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);
|
| [DllImport("adva pi32.dll")]
| internal static extern long RegLoadMUIStrin g(IntPtr hKey,
string
| pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint
Flags,
| string pszDirectory);
| >
| The return type for both functions should be int, not long.
| >
| >
| Mattias
| >
| --
| Mattias Sjögren [C# MVP] mattias @ mvps.org
| http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| Please reply only to the newsgroup.
| >
Oct 9 '06 #5
Well, I know the call is not working because the variable I care about:
pszOutBuf is an empty string. The integer that is returned from the function
call is: 120.

I really need someone to respond that has used the RegLoadMUIStrin g function.

Here is the function delaration:
http://msdn.microsoft.com/library/de...dmuistring.asp

thanks,
-bp

"Willy Denoyette [MVP]" wrote:
And what does RegLoadMUIStrin g call return? You don't check the return value
in your code!!!

Willy.
"lissbpp" <li*****@discus sions.microsoft .comwrote in message
news:8F******** *************** ***********@mic rosoft.com...
| Changing the return types to int had no affect on the outcome of the call.
|
| -brett
|
| "Mattias Sjögren" wrote:
|
| [DllImport("adva pi32.dll")]
| public static extern long RegOpenKeyEx(In tPtr hKey, string
| lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);
|
| [DllImport("adva pi32.dll")]
| internal static extern long RegLoadMUIStrin g(IntPtr hKey,
string
| pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData, uint
Flags,
| string pszDirectory);
| >
| The return type for both functions should be int, not long.
| >
| >
| Mattias
| >
| --
| Mattias Sjögren [C# MVP] mattias @ mvps.org
| http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| Please reply only to the newsgroup.
| >
Oct 9 '06 #6
First thing to do after calling any of the Win32 API's is checking the
return value, this value indicates success or failure. If the return is
success , you can use the argument values returned, if the return value
indicates a failure, you have to inspect the error code or you need to call
GetLastWin32Err or, this depends on the API, that's why you need to check the
API docs first.

In your case 120 means: This function is not supported on this system.
Are you sure you run this on Vista?, the API isn't implemented on anything
lower.

Willy.

"lissbpp" <li*****@discus sions.microsoft .comwrote in message
news:61******** *************** ***********@mic rosoft.com...
| Well, I know the call is not working because the variable I care about:
| pszOutBuf is an empty string. The integer that is returned from the
function
| call is: 120.
|
| I really need someone to respond that has used the RegLoadMUIStrin g
function.
|
| Here is the function delaration:
|
http://msdn.microsoft.com/library/de...dmuistring.asp
|
| thanks,
| -bp
|
| "Willy Denoyette [MVP]" wrote:
|
| And what does RegLoadMUIStrin g call return? You don't check the return
value
| in your code!!!
| >
| Willy.
| >
| >
| "lissbpp" <li*****@discus sions.microsoft .comwrote in message
| news:8F******** *************** ***********@mic rosoft.com...
| | Changing the return types to int had no affect on the outcome of the
call.
| |
| | -brett
| |
| | "Mattias Sjf¶gren" wrote:
| |
| | [DllImport("adva pi32.dll")]
| | public static extern long RegOpenKeyEx(In tPtr hKey, string
| | lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);
| |
| | [DllImport("adva pi32.dll")]
| | internal static extern long RegLoadMUIStrin g(IntPtr hKey,
| string
| | pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData,
uint
| Flags,
| | string pszDirectory);
| | >
| | The return type for both functions should be int, not long.
| | >
| | >
| | Mattias
| | >
| | --
| | Mattias Sjf¶gren [C# MVP] mattias @ mvps.org
| | http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| | Please reply only to the newsgroup.
| | >
| >
| >
| >
Oct 10 '06 #7
I'm not going to sit in here and talk best practices with you; I simply want
to get my code working.

Do you really think I don't know what OS I'm using?

Where did you find the documentation on the 120 error code? Maybe it has to
do with the signature being incorrect, however I'm pretty sure it's right.

-bp
"Willy Denoyette [MVP]" wrote:
First thing to do after calling any of the Win32 API's is checking the
return value, this value indicates success or failure. If the return is
success , you can use the argument values returned, if the return value
indicates a failure, you have to inspect the error code or you need to call
GetLastWin32Err or, this depends on the API, that's why you need to check the
API docs first.

In your case 120 means: This function is not supported on this system.
Are you sure you run this on Vista?, the API isn't implemented on anything
lower.

Willy.

"lissbpp" <li*****@discus sions.microsoft .comwrote in message
news:61******** *************** ***********@mic rosoft.com...
| Well, I know the call is not working because the variable I care about:
| pszOutBuf is an empty string. The integer that is returned from the
function
| call is: 120.
|
| I really need someone to respond that has used the RegLoadMUIStrin g
function.
|
| Here is the function delaration:
|
http://msdn.microsoft.com/library/de...dmuistring.asp
|
| thanks,
| -bp
|
| "Willy Denoyette [MVP]" wrote:
|
| And what does RegLoadMUIStrin g call return? You don't check the return
value
| in your code!!!
| >
| Willy.
| >
| >
| "lissbpp" <li*****@discus sions.microsoft .comwrote in message
| news:8F******** *************** ***********@mic rosoft.com...
| | Changing the return types to int had no affect on the outcome of the
call.
| |
| | -brett
| |
| | "Mattias SjÃf¶gren" wrote:
| |
| | [DllImport("adva pi32.dll")]
| | public static extern long RegOpenKeyEx(In tPtr hKey, string
| | lpSubKey,int ulOptions,int samDesired, out IntPtr phkResult);
| |
| | [DllImport("adva pi32.dll")]
| | internal static extern long RegLoadMUIStrin g(IntPtr hKey,
| string
| | pszValue, StringBuilder pszOutBuf, int cbOutBuf, out int pcbData,
uint
| Flags,
| | string pszDirectory);
| | >
| | The return type for both functions should be int, not long.
| | >
| | >
| | Mattias
| | >
| | --
| | Mattias SjÃf¶gren [C# MVP] mattias @ mvps.org
| | http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| | Please reply only to the newsgroup.
| | >
| >
| >
| >
Oct 10 '06 #8

"lissbpp" <li*****@discus sions.microsoft .comwrote in message
news:8A******** *************** ***********@mic rosoft.com...
| I'm not going to sit in here and talk best practices with you; I simply
want
| to get my code working.
|

If you did apply these best practices and searched the API description in
the SDK doc's for the
signature and the meaning of the return value in you wouldn't even be here.
Anyway, this API isn't yet implemented on the RC1 build, don't know about
RC2 though.

Willy.

Oct 10 '06 #9
Thanks for looking into this for me Willie and sorry about the last post.
I've been a bit frustrated trying to figure out the problem.

-bp

"Willy Denoyette [MVP]" wrote:
>
"lissbpp" <li*****@discus sions.microsoft .comwrote in message
news:8A******** *************** ***********@mic rosoft.com...
| I'm not going to sit in here and talk best practices with you; I simply
want
| to get my code working.
|

If you did apply these best practices and searched the API description in
the SDK doc's for the
signature and the meaning of the return value in you wouldn't even be here.
Anyway, this API isn't yet implemented on the RC1 build, don't know about
RC2 though.

Willy.

Oct 10 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2687
by: salad | last post by:
Due to an earlier posting I read in this newsgroup regarding Office 2007 beta, I downloaded it. After I DL'd it, I got an invitation from MS to get WinVista. I am now wondering if, since both are betas, it is best to buy a new computer? My current computer setup is a Pentium 4, 1 gig memory, 2.66 ghz, 60-80 gig disk drive. MS's requirements for a WinVista computer is A modern processor (800mz)
13
3032
by: Mark Rae | last post by:
Hi, On Friday I attended the Microsoft EVO conference in London where they talked about Vista, Office 2007 and Exchange 2007 and how they all work together beautifully, how they were all "people-ready" etc... I asked a couple of questions about Visual Studio.NET on Vista, especially on 64-bit Vista, and they became *very* nervous... To cut a long story short, Microsoft will not support ANY version of Visual
5
1621
by: guy | last post by:
http://blogs.msdn.com/ericnel/archive/2006/10/17/top-level-technologies-products-not-supported-on-windows-vista.aspx are MS really saying that they do not have a development enviropnment for Vista that will be supported and work out of the box, with no warnings or requirements to disable bits of th o/s from day one? What do we get from Vista besides yet another learning curve, hasle and different bugs to resolve? Guy
56
3644
by: Squishy | last post by:
I tried installing my VS2005 Pro on Vista Ultimate 32 bit RTM today and got errors stating that VS2005 was not compatible with Vista. Microsoft......please pull your finger out of my ass and tell me this is a joke. It must be a joke....because I also have read that VS2002 and VS2003 will not be supported on Vista. This clearly violates Microsoft's own terms of support for these products.
0
1675
by: salad | last post by:
I took the Bart down to San Francisco and joined a couple thousand other nerds to watch the Vista/Office launch. The receptionist was quite pleasant and getting the event packets a smooth process. First we watched the standord keynote session where companies that have implemented Vista extolled its virtues. Vista appears to be a nice operating system. I think the desktop action
6
4276
by: j2ee.singh | last post by:
Hi, I'm looking to buy a new laptop primarily to learn & practice .NET and C#. My Question is: Is there any requirement for .NET and C# in terms of the following Operating Systems: - Windows Vista Home Basic - Windows Vista Business
19
2256
by: =?Utf-8?B?TWlrZTk5MDA=?= | last post by:
When there is a shortcut of our app on the desctop, the app is not run until all the security in control panel of win vista is cleared. What to do to not have this problem. We do not want to tell the customers to do this. -- Mike
2
1725
by: 13Rockes | last post by:
I am in the process of writing programs using VB6 in XP Pro. However, I am thinking about starting over using VB2005 as my company is migrating to Vista. Two questions... What kinds of problems will I have installing and running my VB6 app under Vista? If I develop VB2005 apps under XP, what kinds of problems will I have
2
1994
by: David | last post by:
I purchased a Dell for development and selected Vista Business as the OS. I am mostly working on ASP.net, Visual Studio 2005/2008, and SQL 2005. I am considering a switch back to XP pro (Dell will swap the OS) due to software compatibility and file permission issues with Vista. My Observations: * Reason to choose XP
10
1815
by: nik | last post by:
Hi, I've compiled my application on my vista machine, and it won't run at all on my xp machine. In the windows error report I get Exception code; 0xe0434f4d. I searched for that exception, but didn't see anything related to my problem The xp machine does have vb6 installed on it, could that be an issue? What reasons and solutions for this problem?
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.