Foxtable(狐表)用户栏目专家坐堂 → VB6管理员模式注册COM DLL和控件,反注册,VB.NET也可参考


  共有2777人关注过本帖树形打印复制链接

主题:VB6管理员模式注册COM DLL和控件,反注册,VB.NET也可参考

帅哥哟,离线,有人找我吗?
软件开发订做
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:12 积分:163 威望:0 精华:0 注册:2017/10/8 17:40:00
VB6管理员模式注册COM DLL和控件,反注册,VB.NET也可参考  发帖心情 Post By:2023/5/17 21:23:00 [只看该作者]

VB6管理员模式注册COM DLL和控件,反注册,VB.NET也可参考

有的电脑管理员权限比较高,就自已写个REGSVR32一样的软件来自动注册,或使用VBS,BAT提权后注册。
最好的方法还是使用免注册加载Activex对象的方法。
64位VBA免注册调用32位COM DLL的问题
https://club.excelhome.net/thread-1662929-1-1.html

RegComDll App.Path & "\32_MFCActiveXControl1.ocx"

'reg x64 com dll
RegComDll App.Path & "\64_MFCActiveXControl1.ocx", False

’反注册DLL

RegComDll App.Path & "\32_MFCActiveXControl1.ocx", , True
代码: 
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProc As Long, bWow64Process As Boolean) As Long

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Const SW_SHOWNORMAL = 1


Public Function Is64bit() As Boolean
Dim handle As Long, bolFunc As Boolean
bolFunc = False
handle = GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process")
If handle > 0 Then
IsWow64Process GetCurrentProcess(), bolFunc
End If
Is64bit = bolFunc
End Function


Function RegComDll(DllFile As String, Optional For32Bit As Boolean = True, Optional UnRegComDLL As Boolean)
ShellExecute 0, "runas", "C:\Windows\" & IIf(Is64bit And For32Bit, "SysWOW64", "system32") & "\regsvr32.exe", Chr(34) & DllFile & Chr(34) & IIf(UnRegComDLL, " /U", ""), vbNullString, SW_SHOWNORMAL
End Function


Function RegsvrComDll(DllFile As String, Optional For32BitDll As Boolean = True, Optional UnRegComDLL As Boolean)
Dim Path1 As String
Path1 = "system32"
If Is64bit And For32BitDll Then Path1 = "SysWOW64"
ShellExecute 0, "runas", "C:\Windows\" & Path1 & "\regsvr32.exe", Chr(34) & DllFile & Chr(34) & IIf(UnRegComDLL, " /U", ""), vbNullString, SW_SHOWNORMAL
End Function



 回到顶部