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;
                }
            }             
            }
    

  • 相关阅读:
    责任链模式(Chain of Responsibility)
    模板模式(Template Method)
    组合模式(Composite Pattern)
    原型模式(Prototype Pattern)
    策略模式(Strategy Pattern)
    状态模式(State Pattern)
    增删改查
    安卓sql
    安卓第三次作业
    安卓第四周作业
  • 原文地址:https://www.cnblogs.com/chinaHunk/p/1931333.html
Copyright © 2011-2022 走看看