public static extern int DllRegisterServer(); ...你那个DLL里有这个方法??

解决方案 »

  1.   

    直接调用dllregisterserver这个函数就可以了。不需要用regsvr32。
      

  2.   

    你可以通过调用loadlibrary getmodulehandle getprocedureaddress来动态调用dll,而避免使用attribute。
      

  3.   

    不知道,这dll文件是别人给的测试用的
      

  4.   

    额,我是小白,刚刚实习不懂这个。只是想注册dll文件,因为我这里不用调用dll文件进行开发。这些dll文件都是公司以前封装好的,能说的详细点吗版主大大
      

  5.   

    dll这个函数不是前面有[DllImport(@"C:\Users\wh\Desktop\啊啊\ECCartoExtension.dll")]吗?这个dll路径又不能写变量,怎么办版主大大
      

  6.   

    写一个批处理文件比如a.bat,然后运行该批处理。
    regsvr32 /s C:\Users\wh\Desktop\ECCartoExtension.dll 
    if errorlevel 1 echo ERROR!&goto :EOF
    echo OK.
    试试看。
      

  7.   

    看效果请将a.bat的输出重定向到一个文本文件比如out.txt中,
    即shell执行命令
    a.bat >out.txt
    然后读文件out.txt的内容。或者你先在cmd窗口中执行a.bat看显示啥。
      

  8.   


    实在不好意思,我太菜了,不知道怎么获取这个输出的信息:“OK”或“ERROR”
      

  9.   

    C#我也不熟,仅供参考:
    Dim procID As Integer
    Dim newProc As Diagnostics.Process
    newProc = Diagnostics.Process.Start("CMD /c a.bat >out.txt")
    procID = newProc.Id
    newProc.WaitForExit()
    Dim procEC As Integer = -1
    If newProc.HasExited Then
        procEC = newProc.ExitCode
    End If
    //读文件out.txt的内容
      

  10.   

    或者Dim procID As Integer
    Dim newProc As Diagnostics.Process
    newProc = Diagnostics.Process.Start("regsvr32 /s C:\\Users\\wh\\Desktop\\ECCartoExtension.dll")
    procID = newProc.Id
    newProc.WaitForExit()
    Dim procEC As Integer = -1
    If newProc.HasExited Then
        procEC = newProc.ExitCode //procEC==0成功,否则失败
    End If
      

  11.   

    我按照这个修改了一下,但是它不管是否注册成功都都是注册成功。麻烦您再指导指导
    if(suffix=="dll")
                    {
                        string commd = "regsvr32 \"" + num+"\"";
                        Process p = new Process();
                        p.StartInfo.FileName = "cmd.exe";//设定程序名
                        p.StartInfo.Arguments = "";
                        p.StartInfo.UseShellExecute = false;//关闭Shell的使用
                        p.StartInfo.RedirectStandardInput = true;//重定向标准输入
                        p.StartInfo.RedirectStandardOutput = true;//重定向标准输出
                        p.StartInfo.RedirectStandardError = true;//重定向错误输出
                        p.StartInfo.CreateNoWindow = false;//设置不显示窗口
                        int n;
                        p.Start();//启动
                        p.StandardInput.WriteLine(@"regsvr32 /s C:\Users\dview\Desktop\zhuc\插件2\GPSubPoints.dll");
                        n = p.Id;
                        p.StandardInput.WriteLine("exit");//退出DOS,注释后DOS窗体需要手动关闭
                        p.WaitForExit();//等待管理进程退出(DOS)
                        int pExit = -1;
                        if (p.HasExited)
                        {
                            pExit = p.ExitCode;//proEC==0成功,否则失败
                            if (pExit == 0)
                            {
                                MessageBox.Show("注册成功");
                            }
                        }                    //p.StandardInput.WriteLine(commd);//参数为DOS命令
                        dll++;
                    }
                    else if (suffix == "ttf")
      

  12.   

    改为
    string commd = "regsvr32 \"" + num+"\"";
    Process p = new Process();
    p.StartInfo.FileName = "regsvr32.exe";//设定程序名
    p.StartInfo.Arguments = "/s C:\\Users\\dview\\Desktop\\zhuc\\插件2\\GPSubPoints.dll";
    p.StartInfo.UseShellExecute = false;//关闭Shell的使用
    p.StartInfo.RedirectStandardInput = false;//重定向标准输入
    p.StartInfo.RedirectStandardOutput = false;//重定向标准输出
    p.StartInfo.RedirectStandardError = false//重定向错误输出
    p.StartInfo.CreateNoWindow = false;//设置不显示窗口
    int n;
    p.Start();//启动
    p.WaitForExit();//等待管理进程退出(DOS)
    int pExit = -1;
    if (p.HasExited)
    {
      pExit = p.ExitCode;//==0成功,否则失败
      if (pExit == 0)
      {
          MessageBox.Show("注册成功");
      }
    }
    再试试?