我用abc10 大虾 的下列代码对其他ocx控件进行注册,都能注册成功,但
注册Vsflex7.ocx总是出错。望各位大虾指教。谢谢****'注册、反注册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
注册Vsflex7.ocx总是出错。望各位大虾指教。谢谢****'注册、反注册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
解决方案 »
- 100分求问ADO连接SQL的简单问题
- 如何获得RichTextBox光标所在行的字符串?(一整行的数据)
- 用哪个控件做出像“internet explore”上那样的“菜单拦”??急!!在线等!
- 如何给程序的运行加点时间限制??
- 如何用自己的图片代替RichTextBox中的滚动条
- 如何隐藏按钮?
- 请问一下TCP(UDP)反向监听的可行性
- 如何判断程序是否是第一次运行?
- 各位兄弟!你们说值不值!
- 一个非常简单的问题,但对我又是非常的重要,你想要这50分吗,快来吧,各位大虾
- 1.str1 为String,现在要逐个扫描str1中的元素,如果是空格则让它变为'-'
- win2000打包成的exe文件在win98上安装出错,为什么?
并且在窗口中引用该控件,则出错(不出现该控件)