Static void main (string [] ARGs) {// connect to the AutoCAD application registrykey regk = registry. localmachine; registrykey software = regk. opensubkey ("Software \ Autodesk \ AutoCAD \ r17.1", false); If (software = NULL) {console. writeline ("AutoCAD 2008 startup failed! "); Return;} // determine whether the registry file already exists // If (isreg) // {console. writeline ("the Registry file already exists, and AutoCAD 2008 starts normally .. "); // 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 ("Events", 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; // whether the registry file contains 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 ;}}}