请登录[¤ 阳光论坛 ¤]参与讨论


阳光宝宝
90

 □ 主题: VB中动态注册DLL和OCX
 □ 内容: 1楼

      第一种,很简单,很方便,很常用 
       
      查看源代码打印帮助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  
       
      用哪种方法自己选择,不过效果都是一样 
      
——
      
争分夺秒背单词 → against  prep.倚在;逆,对着
 □ 发帖时间:2012-10-25|16:04:48 |回复|返回|

 页次:1/1页 每页10  本主题贴数0 分页: 1


你还没有登录论坛,所以不能发表你的意见。你可以选择:

1、我已注册,我要

2、我还没注册,我要

3、太麻烦了,我还是

Go Top

Copyright by(C)2003-2015 http://abc.sy578.cn