RegisterTypeLibForUser call doesn't seem to work - any ideas ?

Posted by Mmarquee on Stack Overflow See other posts from Stack Overflow or by Mmarquee
Published on 2010-03-24T09:38:00Z Indexed on 2010/03/24 9:43 UTC
Read the original article Hit count: 735

This is really a follow on question to a previous one, where I need to register applications, TLBs and OCXs per user, rather than into HKLM. I have written the following code - based on answers here and elsewhere, BUT the TLB is not registered - no error is thrown, just nothing happens (this code snippet comes from the Embarcadero website.

procedure RegisterTypeLibrary(TypeLib: ITypeLib; const ModuleName: string);
var
  Name: WideString;
  HelpPath: WideString;
  RegisterTypeLibForUser : function(tlib: ITypeLib; szFullPath, szHelpDir: POleStr): HResult; stdcall;
  res : HResult;
begin
  Name := ModuleName;
  HelpPath := ExtractFilePath(ModuleName);
  res:=RegisterTypeLib(TypeLib, PWideChar(Name), PWideChar(HelpPath));
  if res <> S_OK then begin
    @RegisterTypeLibForUser:=GetProcAddress(GetModuleHandle('oleaut32.dll'), 'RegisterTypeLibForUser');
    if (@RegisterTypeLibForUser <> nil) then begin
      res:=RegisterTypeLibForUser(TypeLib, PWideChar(Name), PWideChar(HelpPath));
    end;
  end;
  //MessageBox(GetForegroundWindow, PChar(IntToHex(res, 8)), nil, MB_OK);
  OleCheck(res);
end;

Anyone got any pointers as I am now lost.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about windows-7