谁有好的 程序自动注册dll等控件 的原代码?
在启动的时候判断如果已经注册了,那就跳过注册dll项。

解决方案 »

  1.   

    谁知道如何判断某个 dll 已经注册?
      

  2.   

    对于 ocx ,如果在 system 或 exe 目录中存在,在工程中引用了编译后的 exe 运行时会自动注册。而 dll 则不能自动注册,可以使用 createobject() 建立对象,如果出错,则使用 shell "regsvr32 /s dll文件名" 来注册它。
      

  3.   


    On Error GoTo aErr    Dim dllObj As Object, dllVal As String, regTry As Boolean
        Set dllObj = CreateObject("xxx.yyyy")    '你的类名
        Set dllObj = Nothing
        
        Exit sub
        
    aErr:
        If Err.Number = 429 And Not regTry Then
            'dll错误且库存在,尝试注册它一次(只能一次,否则会死循环)
            If Dir("dll文件名") <> "" Then
                '带 /s 参数运行 regsvr32,不显示信息框
                Shell "Regsvr32 " & Chr(34) & "dll文件名" & Chr(34) & " /s", vbHide
                regTry = True
                Resume
            End If
        End If
        
        msgbox "对象创建失败"