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.
Update :
Thanks for all the help and suggestions, so to clarify ...
As I understand that it, I shouldn't require elevated permission, and so this should to be working, but I could be wrong. Application isn't virtualized (or at least it isn't meant to be), at the moment it just calls the above code, and nothing else.
If I run it as admin it works (or at least doesn't throw an error), not elevating it gives me an error. So can I just not do this at all, or am I doing it wrong? This is the same as when I register it via regsvr32
, although that is a slightly different question - how to do the same, but for OCX controls.