RegisterTypeLibForUser call doesn't seem to work - any ideas ?
- by Mmarquee
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.