The Registry obtains the EXE location + the process class starts the EXE + parameter to enable the EXE to open the specified file

Source: Internet
Author: User
  ///   <Summary>          ///  Start the CAD of the Local Machine and browse the DWG diagram in the CAD.  ///   </Summary>          ///   <Param name = "path">  Cad.exe location  </Param>          ///   <Param name = "dwgfile">  Full path of dwgfile  </Param>          Public  Void Startcad2004 ( String Path, String  Dwgfile) {PROCESS p = New  Process (); p. startinfo. filename = Path; //  Start CAD of the Local Machine P. startinfo. Arguments = Dwgfile ;//Set the DWG file to be opened by CADP. Start ();////Start CAD of the Local Machine}  ///  <Summary>         ///  Obtain the CAD path  ///   </Summary>         ///   <Param name = "path">  CAD location read from the Registry  </Param>         ///   <Returns> </returns>          Public   Bool Getcadpath ( Out   String Path) {path = ""  ; Registrykey key_localmachine = Registry. localmachine;  //  Registrykey key_cad = key_localmachine.opensubkey ("Software \ Autodesk \ AutoCAD \ r16.2 \ ACAD-4001: 804 \", false );  //  Cad2006 Registry address  //  Registrykey key_cad = key_localmachine.opensubkey ("Software \ Autodesk \ AutoCAD \ r16.0 \ ACAD-201: 804 \", false );  // Cad2004 Registry address  //  Any version of CAD is startedProgram              /*  This value features "EXE" "DWG file "*  */  Registrykey key_cad = Key_localmachine.opensubkey ( "  Software \ Classes \ applications \ acad.exe \ shell \ open \ command  " , False  );  If (Key_cad! =Null  ){  String Cadpath = key_cad.getvalue ( "" ). Tostring (); //  Get startup path Matchcollection MC = RegEx. Matches (cadpath, "  \"(? <Cadpath> .*)\"  " ); //  Only the first acad.exe path is obtained. Cadpath = mc [ 0 ]. Groups [ " Cadpath  "  ]. Value; Path = Cadpath;  Return   True  ;}  Return   False  ;} 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.