RegisterTLB - register Typelib
Author: stb (talk, contrib) |
Description
Deprecated by: NSIS 2.01 - Library header file.
It took me some time to learn the System plug-in and make this working, so I posted my achievements for anyone who may need this.
My motivation was to register stdole2.tlb as I install VB6 runtimes. Microsoft's installers (PDW and VSI) seem to register this, too. The NSIS Wiki tipp (How to install the VB6 runtimes) does not register this file, supplied version of UpgradeDll isn't able to register typelibs at all.
It seems that on my PC (Windows XP) running this causes stdole2.tlb to be registered for the first time. But VB6 apps (and VB6 and Office) are installed already so I don't know whether it really is necessary or a "should do". Nevertheless: Here's the function including call example. I didn't test it widely yet but regarding to MSDN it should work on Win95 and newer.
Function Call
You can call this function like this:
Push "C:\WINDOWS\System32\stdole2.tlb" Call RegisterTlb
The Function
Function RegisterTlb Exch $R0 ; save old R0 and get filename as R0 Push $R1 ; save R1 Push $R2 ; save R2 ; now register TLB file R0 StrCpy $R1 0 ; init R1 with 0 (maybe not necessary) System::Call "Oleaut32::LoadTypeLib(w, *i) i (R0, R1R1) .R2" ; R2 contains result, 0 if ok IntCmp $R2 0 cont LogText "LoadTypeLib returned $R2 with $R0" ; debug MessageBox MB_OK "LoadTypeLib returned $R2 with $R0" Goto exit cont: ; now R1 contains pointer to typelib System::Call "Oleaut32::RegisterTypeLib(i, w, i) i (R1, R0, 0) .R2" ; R2 contains result, 0 if ok IntCmp $R2 0 exit LogText "RegisterTypeLib returned $R2 with $R1, $R0" ; debug MessageBox MB_OK "RegisterTypeLib returned $R2 with $R1, $R0" exit: ;; debug MessageBox MB_OK "RegisterTlb: all ok" Pop $R2 ; R2 restore Pop $R1 ; R1 restore Pop $R0 ; R0 restore FunctionEnd