[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

Need help with RegLoadMUIString function


I've attached some Delphi 2010 source code that I am trying to get to work. It uses the RegLoadMUIString function. I have obviously messed up one of the parameter since I get an error 87 when I execute it. The code is simple. It attempts to return the DisplayName and Description of the NetLogon service. You must have at least Vista or Windows 2008. I'm using Windows 7.

I need help in getting this simple (?) function to work.
Can someone point out my mistake?
Thanks in advance for useful help.

Ken McClain
RegLoadMUIString.zip
0
softbreeze
Asked:
softbreeze
  • 2
1 Solution
 
epasquierCommented:
ok, first, you are having this :
ERROR_INVALID_PARAMETER 87 (0x57)

I cannot pinpoint your problem, but simplified the function and tested it successfully with Delphi 2007.
maybe it will work for you.
function _RegLoadMUIString(aService,aValue: WideString): WideString;
var
 Reg:     TRegistry;
 OBuf:    array[0..1023] of WideChar;
 OBufSize:DWORD;
 OSize:   Cardinal;
 Rtn:     Longint;
begin
 FillChar(OBuf,sizeof(OBuf),#0);
 OSize := 0;
 Reg := TRegistry.Create;
 try
  Reg.RootKey := HKEY_LOCAL_MACHINE;
  if (Reg.OpenKey(aService,FALSE)) then
   begin
    Rtn:= RegLoadMUIString(Reg.CurrentKey,
                             PWideChar(aValue),
                             PWideChar(@OBuf),
                             sizeof(OBuf) Div sizeof(WideChar),
                             OSize,
                             0,
                             nil);
    if Rtn = 0
     then Result := OBuf
     else Result := 'Error: ' + IntToStr(Rtn);
   end else Result:='Invalid Key :'+aService;
 except 
  on E: Exception do Result := 'Exception: ' + E.Message;
 end; //try
 Reg.Free;
end;

Open in new window

0
 
softbreezeAuthor Commented:
Thank you. It worked perfectly.
Ken
0
 
softbreezeAuthor Commented:
Thanks
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now