绝对给分
解决方案 »
- 那位高手知道.edf是什么文件?
- 求教:关于Toolbar的问题
- 请问哪里有vb6.0开发网络程序的电子文章看
- 如何使在点击Treeview中的节点时,对应节点的名称显示在datagrid 和 listview 列表中
- 请教自制控件初始化的问题?
- 有关音乐和视频文件的问题?
- 如何实现两个datalist与一组textbox的数据关联啊??100分
- 如何将EXCEL 数据进行90度的位移?
- 作很多无规律的表格套打,有没有什么好办法...???急急急
- 如何解决 执行阶段错误"713" 说物件类别没有注册,(急,在线等)
- 谁有CoolMenu 3.0的注册机?
- 如何读取*.csv的行数,不用循环做,在线等。。。
Option Explicit
'模块名称:mdlRegServer
'模块功能:不使用regServer.exe 来注册ActiceX OCX ,DLL
'作者:[email protected] 从APIGUIDE整理得来
'更新日期:2003-7-29 7:59:58 PM
'相关模块:
'相关文件:
'预期读者和阅读建议:
'使用方法:
' 注册 RegisterServer Me.hWnd, "c:\somedir\some.ocx", True
' 注消 RegisterServer Me.hWnd, "c:\somedir\some.ocx", FalsePrivate Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long
Private Const ERROR_SUCCESS = &H0Public Function RegisterServer(hWnd As Long, DllServerPath As String, bRegister As Boolean)
On Error Resume Next
'*关键外部调用:FileExist
If Not mdlUtilities.FileExist(DllServerPath) Then
MsgBox "Err: Cann't find the path [" & DllServerPath & "] !"
Exit Function
End If
'***************
Dim lb As Long, pa As Long
lb = LoadLibrary(DllServerPath)
If bRegister Then
pa = GetProcAddress(lb, "DllRegisterServer")
Else
pa = GetProcAddress(lb, "DllUnregisterServer")
End If
'***************
If CallWindowProc(pa, hWnd, ByVal 0&, ByVal 0&, ByVal 0&) = ERROR_SUCCESS Then
MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Successful"
Else
MsgBox IIf(bRegister = True, "Registration", "Unregistration") + " Unsuccessful"
End If
'***************
FreeLibrary lb
End Function
'***********************************************************
'*希望能够对你有所帮助!
'***********************************************************'*欢迎访问我的网站,给我的作品提宝贵意见!希望和大家交朋友!
http://www.softboyzhou.com
'*下载EasyDialog:
http://www.softboyzhou.com/download/EasyDialog.asp
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Any, ByVal wParam As Any, ByVal lParam As Any) As Long
Private Sub Form_Load()
On Error Resume Next
'我们可以调用一个api函数,而无需声明它
Dim lb As Long, pa As Long
'map 'user32' into the address space of the calling process.
Lb = LoadLibrary("user32")
'retrieve the address of 'SetWindowTextA'
pa = GetProcAddress(lb, "SetWindowTextA")
'Call the SetWindowTextA-function
CallWindowProc pa, Me.hWnd, "Hello !", ByVal 0&, ByVal 0&
'unmap the library's address
FreeLibrary lb
End Sub
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32.dll" (ByVal hModule As Long, ByVal lpProcName As String) As LongPrivate Sub Command1_Click()
Dim Modulehwnd As Long, DllFileName As String
Dim ProcAddr As Long, NameOfProcedure As String
Dim Result As Long
DllFileName = "C:\Test.dll" & Chr(0)
Modulehwnd = LoadLibrary(DllFileName)
If Modulehwnd = False Then
Debug.Print "Error to load this dll or exe"
Exit Sub
End If
NameOfProcedure = "DllRegisterServer" & Chr(0)
ProcAddr = GetProcAddress(Modulehwnd, NameOfProcedure)
If ProcAddr = False Then
Debug.Print "Can't get this address of procedure"
Exit Sub
End If
Result = CallWindowProc(ProcAddr, Me.hwnd, 0&, 0&, 0&)
If Result = 0 Then
Debug.Print "The address of this DLL's exported function is: "; Result
Else
Debug.Print "Error to register" & Result
End If
FreeLibrary DllFileName
End Sub