如何使vb的外部控件自动注册

seekafei 2003-09-30 05:51:55
我在程序中使用了外部控件"BciButton"和“vsflexgrid 7.0”但把程序做成
安装文件后,再装在没有注册上面两控件的计算机上时,运行程序出错,希望
各位大虾给我解决注册控件的方法,最好能在程序中自动注册,谢谢
...全文
95 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangliyun01 2003-10-02
  • 打赏
  • 举报
回复
楼上的程序太多,不过我十分佩服他,说实话,我没有耐心看完这段程序,只觉得应该差不多吧。我用来注册控件的方法很简单 ,我用setp factory来分析(就在每个控件的属性_高级里面有个自动分析的工具)很是好使
abc10 2003-09-30
  • 打赏
  • 举报
回复
*****'注册、反注册OCX、DLL文件
Private Declare Function LoadLibraryRegister Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function CreateThreadForRegister Lib "kernel32" Alias "CreateThread" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByVal lParameter As Long, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function GetProcAddressRegister Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function FreeLibraryRegister Lib "kernel32" Alias "FreeLibrary" (ByVal hLibModule As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, lpExitCode As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal dwExitCode As Long)
Public Function fun_RegServer(ByVal filename As String) As Boolean
'注册
fun_RegServer = RegSvr32(filename, False)
End Function

Public Function fun_UnRegServer(ByVal filename As String) As Boolean
'反注册
fun_UnRegServer = RegSvr32(filename, True)
End Function

Private Function RegSvr32(ByVal filename As String, bUnReg As Boolean) As Boolean
Dim lLib As Long
Dim lProcAddress As Long
Dim lThreadID As Long
Dim lSuccess As Long
Dim lExitCode As Long
Dim lThread As Long
Dim bAns As Boolean
Dim sPurpose As String
sPurpose = IIf(bUnReg, "DllUnregisterServer", "DllRegisterServer")
If Dir(filename) = "" Then Exit Function
lLib = LoadLibraryRegister(filename)
'载入文件
If lLib = 0 Then Exit Function
lProcAddress = GetProcAddressRegister(lLib, sPurpose)
If lProcAddress = 0 Then
'不是ActiveX控件
FreeLibraryRegister lLib
Exit Function
Else
lThread = CreateThreadForRegister(ByVal 0&, 0&, ByVal lProcAddress, ByVal 0&, 0&, lThread)
If lThread Then
lSuccess = (WaitForSingleObject(lThread, 10000) = 0)
If Not lSuccess Then
Call GetExitCodeThread(lThread, lExitCode)
Call ExitThread(lExitCode)
bAns = False
FreeLibraryRegister lLib
Exit Function
Else
bAns = True
End If
CloseHandle lThread
FreeLibraryRegister lLib
Else
FreeLibraryRegister lLib
End If
End If
RegSvr32 = bAns
End Function

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧