第一种,很简单,很方便,很常用 查看源代码打印帮助1 Shell "Regsvr32 /S " & """" & App.Path & "ASYCFILT.DLL" & """" 第二种,调用API Private Declare Function FreeLibrary Lib "kernel32" (ByVal hModule As Long) As Long Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lpFileName As String) As Long Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long Private Declare Function CallWindowProcA Lib "user32" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long ''注册。 Public Function DllRegister(ByVal FileName As String) As Boolean Dim hModule As Long Dim pAddress As Long hModule = LoadLibraryA(FileName) If hModule Then pAddress = GetProcAddress(hModule, "DllRegisterServer") If pAddress Then If CallWindowProcA(pAddress, 0, 0, 0, 0) Then DllRegister = True End If Call FreeLibrary(hModule) End If End Function ''反注册。 Public Function DllUnregister(ByVal FileName As String) As Boolean Dim hModule As Long Dim pAddress As Long hModule = LoadLibraryA(FileName) If hModule Then pAddress = GetProcAddress(hModule, "DllUnregisterServer") If pAddress Then If CallWindowProcA(pAddress, 0, 0, 0, 0) Then DllUnregister = True End If Call FreeLibrary(hModule) End If End Function 用哪种方法自己选择,不过效果都是一样
|