HOWTO: Programmatically Register and Unregister .OCX Files
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q173091&

解决方案 »

  1.   

    sorry, try something likePrivate Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As LongPrivate Declare Function LoadLibrary Lib "kernel32" Alias
    "LoadLibraryA" (ByVal lpLibFileName As String) As LongPrivate Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As LongPrivate 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 LongPrivate Const ERROR_SUCCESS = &H0    Dim lb As Long, pa As Long
        lb = LoadLibrary(DllServerPath) 'change DllServerPath to the Path to your DLL
        
        pa = GetProcAddress(lb, "DllRegisterServer")    If CallWindowProc(pa, hWnd, ByVal 0&, ByVal 0&, ByVal 0&) =
    ERROR_SUCCESS Then
            MsgBox "Successful"
           End If    FreeLibrary lbactually, you could just call
    shell "regsv32 " & PathToYourDLL
      

  2.   

    HINSTANCE hLib = LoadLibrary(pszDllName);if (hLib < (HINSTANCE)HINSTANCE_ERROR)
    {
     DisplayMessage(IDS_LOADLIBFAILED, pszDllName); //unable to load DLL
     iReturn = FAIL_LOAD;                   //unable to load DLL
    }// Find the entry point.
    (FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, 
       _T(“DllRegisterServer”));
    if (lpDllEntryPoint != NULL)
     (*lpDllEntryPoint)();
    else
       //unable to locate entry point
      

  3.   

    as you known,"regsvr32" does not work well sometimes
      

  4.   

    楼上两位给我的例子好象是调用DLL的方法啊,我需要的是注册DLL的方法
    GetProcAddress不是找到DLL中函数地址的API么?
      

  5.   

    而且按照这个方法在win98下面会出错误