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
LVL 1
softbreezeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
softbreezeAuthor Commented:
Thank you. It worked perfectly.
Ken
0
softbreezeAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.