你担心的是 Shell 执行的 Regsvr32 与你的主程序是异步执行的!现在你可以引用 Windows Script Host Object Model 使 Shell 执行的 Regsvr32 与你的主程序是同步执行! 参阅 如何使几个 EXE 线性同步执行,而不并行异步执行 http://www.csdn.net/expert/topic/372/372167.shtm '引用 Windows Script Host Object Model Private Sub Command1_Click() Dim x As New IWshRuntimeLibrary.IWshShell_Class 'v2.0 'Dim x As New IWshRuntimeLibrary.WshShell 'v5.6 x.Run "regsvr32 D:\MyVBP\eWskPlus\eWskPlus.dll /s", , True End Sub
这一句 Dim x As New IWshRuntimeLibrary.IWshShell_Class 'v2.0 运行时出错。
建立一 reg 文件,加入以下內容 :)REGEDIT4
; ==========
; .DLL files
; ==========[HKEY_CLASSES_ROOT\.dll]
"Content Type"="application/x-msdownload"
@="dllfile"[HKEY_CLASSES_ROOT\dllfile]
@="Application Extension"[HKEY_CLASSES_ROOT\dllfile\Shell\Register\command]
@="regsvr32.exe \"%1\""[HKEY_CLASSES_ROOT\dllfile\Shell\UnRegister\command]
@="regsvr32.exe /u \"%1\""; ==========
; .OCX files
; ==========[HKEY_CLASSES_ROOT\.ocx]
@="ocxfile"[HKEY_CLASSES_ROOT\ocxfile]
@="OCX"[HKEY_CLASSES_ROOT\ocxfile\Shell\Register\command]
@="regsvr32.exe \"%1\""[HKEY_CLASSES_ROOT\ocxfile\Shell\UnRegister\command]
@="regsvr32.exe /u \"%1\""
比如,对应regsvr32的 /s /u命令。
Shell 执行的 Regsvr32 与你的主程序是异步执行的!现在你可以引用 Windows Script Host Object Model
使 Shell 执行的 Regsvr32 与你的主程序是同步执行!
参阅
如何使几个 EXE 线性同步执行,而不并行异步执行
http://www.csdn.net/expert/topic/372/372167.shtm
'引用 Windows Script Host Object Model
Private Sub Command1_Click()
Dim x As New IWshRuntimeLibrary.IWshShell_Class 'v2.0
'Dim x As New IWshRuntimeLibrary.WshShell 'v5.6
x.Run "regsvr32 D:\MyVBP\eWskPlus\eWskPlus.dll /s", , True
End Sub
Dim x As New IWshRuntimeLibrary.IWshShell_Class 'v2.0
运行时出错。
http://www.applevb.com/sourcecode/control.zip
动态注册和反注册ActiveX的控件
现在的问题是怎样把控件注册掉,就象regsvr32 /u的效果一样?
使用如下语句:
Declare Function DLLUnSelfRegister Lib "dec.dat" (ByVal lpDllName As String) As IntegeriReg = DLLUnSelfRegister(App.Path + "\dec.dat")却没有效果。
请问是哪里不正确?
如果是两个控件,同时需要注册和反注册,该怎么办?