我做了一个简单的安装程序,在IE5的系统中,我需要把msxml3.dll拷贝到system32目录下,因为msxml3.dll是普通的dll,所以我以为不用注册就可以用,但是安装好的程序不能加载msxml3.dll,我手工方式注册了msxml3.dll后,虽然系统显示注册成功,但是查看注册表并没有注册进去,随后我的程序就能正确运行了(为什么?)。我试图在VB做的安装程序里用WINEXEC来注册msxml3.dll,但是不同于在命令行里注册,无法注册成功,因此我的程序始终不能在IE5的环境下运行(不能找到msxml3.dll),还请各位指教。

解决方案 »

  1.   

    参考:
    http://www.microsoft.com/china/msdn/workshop/joyofsax.asp
      

  2.   

    关于使用api注册,可以参考:
    Option Explicit
    Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lLibFileName As String) As Long
    Private Declare Function CreateThread Lib "kernel32" (lThreadAttributes As Any, ByVal lStackSize As Long, ByVal lStartAddress As Long, ByVal larameter As Long, ByVal lCreationFlags As Long, lThreadID As Long) As Long
    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal lMilliseconds As Long) As Long
    Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lProcName As String) As Long
    Private Declare Function FreeLibrary Lib "kernel32" (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, lExitCode As Long) As Long
    Private Declare Sub ExitThread Lib "kernel32" (ByVal lExitCode As Long)
    'Purpose   :    This function registers and Unregisters OLE components
    'Inputs    :    sDllPath                        The path to the DLL/OCX
    '               bRegister                       If True Registers the control, else unregisters control
    'Outputs   :    Returns True if successful
    'Author    :    Andrewb
    'Date      :    04/09/2000
    'Notes     :    This effectively replaces RegSvr32.exe by loading the library and
    '               calling the register or unregister functions exposed by all OLE components.
    'Revisions :
    Function RegisterServer(ByVal sDllPath As String, Optional bRegister As Boolean = True) As Boolean
    Dim lLibAddress As Long, lProcAddress As Long, lThreadID As Long, lSuccess As Long, lExitCode As Long, lThread As Long
    Dim sRegister As String
    Const clMaxTimeWait As Long = 20000     'Wait 20 secs for register to
    complete
    On Error GoTo ExitFunc
    If Len(sDllPath) > 0 And Len(Dir(sDllPath)) > 0 Then
    'File exists
    If bRegister Then
    sRegister = "DllRegisterServer"
    Else
    sRegister = "DllUnregisterServer"
    End If
    'Load library into current process
    lLibAddress = LoadLibraryA(sDllPath)
    If lLibAddress Then
    'Get address of the DLL function
    lProcAddress = GetProcAddress(lLibAddress, sRegister)
    If lProcAddress Then
    'Found interface, make call to component
    lThread = CreateThread(ByVal 0&, 0&, ByVal lProcAddress, ByVal 0&, 0&, lThread)
    If lThread Then
    'Created thread
    lSuccess = (WaitForSingleObject(lThread, clMaxTimeWait) = 0)
    If Not lSuccess Then
    'Failed to register, close thread
    Call GetExitCodeThread(lThread, lExitCode)
    Call ExitThread(lExitCode)
    RegisterServer = False
    Else
    'Register control
    RegisterServer = True
    Call CloseHandle(lThread)
    End If
    End If
    Else
    'Object doesn't expose OLE interface
    FreeLibrary lLibAddress
    End If
    Call FreeLibrary(lLibAddress)
    End If
    End If
    ExitFunc:
    On Error GoTo 0
    End Function
      

  3.   

    直接安装ms xml3.0的安装包这样问题少一些
      

  4.   

    这种方法我也我也试过,IE5的环境下,sDllPath=C:\WINNT\system32\msxml3.0              lLibAddress = LoadLibraryA(sDllPath) ,lProcAddress = GetProcAddress(lLibAddress, sRegister),lProcAddress =0,也就是说找不到DllUnregisterServer的内部函数
      

  5.   

    我做的是安装程序,所以不能手工方式再安装msxml3.0包
      

  6.   

    用 regsvr32 注册 COM 组件。
      

  7.   

    我也试过,命令行中可以用regsvr32来注册,但是程序中调用显示不能注册的信息,而我恰恰要在程序中注册该控件
      

  8.   

    这些工作应该有安装程序来作,比如 InstallShield