zoukankan      html  css  js  c++  java
  • 外部启动CAD

     static void Main(string[] args)
            {
                 // 连接至 AutoCAD 应用程序   
                RegistryKey RegK = Registry.LocalMachine;
                RegistryKey software = RegK.OpenSubKey("Software\\Autodesk\\AutoCAD\\R17.1", false);
    
                if (software == null)
                {
                    Console.WriteLine("AutoCAD 2008启动失败!");
                    return;
                }
                // 判断注册表文件是否已经存在
                //if (IsReg) 
                //{
                    Console.WriteLine("注册表文件已存在,AutoCAD 2008正常启动..");
                    //Console.ReadLine();
                    System.Type AcadType = System.Type.GetTypeFromProgID("AutoCAD.Application");
                    Object acad= System.Activator.CreateInstance(AcadType);
                    AcadType.InvokeMember("visible", System.Reflection.BindingFlags.SetProperty, null, acad, new object[] { true });
                    Object documents = AcadType.InvokeMember("Documents", System.Reflection.BindingFlags.GetProperty, null, acad, null);
                    Object document = documents.GetType().InvokeMember("Add", System.Reflection.BindingFlags.InvokeMethod, null, documents, null);
                    //Autodesk.AutoCAD.Interop.AcadApplicationClass ICad = new AcadApplicationClass();
                    //ICad.Visible = true;
                    //ICad.WindowState =Autodesk.AutoCAD.Interop.
                    //return;
                //} 
        }
            // 注册表文件是否存在
            static bool IsReg
            {
                get 
                {
                    RegistryKey Key = Registry.LocalMachine.OpenSubKey("Software\\Autodesk\\AutoCAD\\R17.1\\ACAD-6002:804\\Applications\\SmartSoft", false);
                    
                    if (Key == null)
                        return false;
    
                    Key.Close();
                    return true;
                }
            }             
            }
    

  • 相关阅读:
    python 获取Excel 的内容
    python 获取文件Excel 的行数与列数
    python 读取Excel 取出表头(列名)
    DRF的视图组件
    Redis
    Git的故事
    DRF的JWT用户认证
    DRF的三大认证组件
    DRF的序列化组件
    DRF的请求响应组件
  • 原文地址:https://www.cnblogs.com/chinaHunk/p/1931333.html
Copyright © 2011-2022 走看看