Secondary Development of CAD and Secondary Development of cad

Source: Internet
Author: User

Secondary Development of CAD and Secondary Development of cad

The Secondary Development of CAD can be implemented by writing extended DLL. The DLL function can be called by CAD.

However, you must use the netload command to load the dll to CAD before calling.

You can modify the Registry. When the CAD software is started, the extended DLL is automatically loaded.

To this end, I wrote a function to easily modify the Registry to automatically load the dll!

This function supports various versions of cad.

1 // strCadRegKey = "HLD_CAD_Import"; // unique registration ID available company name and program name 2 // strDll file path 3 private bool WriteRegistryKey (string strDll, string strCadRegKey) 4 {5 try 6 {7 RegistryKey localMachine = Registry. localMachine; 8 RegistryKey SOFTWARE = localMachine. openSubKey ("SOFTWARE", true); 9 RegistryKey Autodesk = SOFTWARE. openSubKey ("Autodesk", true); 10 RegistryKey AutoCAD = Autodesk. openSubKey ("AutoCAD", true ); 11 12 int result = 0; 13 foreach (string subDir in GetRegSubDir (AutoCAD, "R") 14 {15 try16 {17 RegistryKey CadVersion = AutoCAD. openSubKey (subDir, true); 18 19 string AcadVersion = GetRegSubDir (CadVersion, "ACAD -"). firstOrDefault (); 20 RegistryKey ACAD = CadVersion. openSubKey (AcadVersion, true); 21 22 RegistryKey Applications = ACAD. openSubKey ("Applications", true); 23 24 // Delete the old record 25 try26 {27 Applica Tions. deleteSubKeyTree (strCadRegKey); 28} 29 catch (Exception ex) 30 {} 31 32 RegistryKey MXCAD = Applications. createSubKey (strCadRegKey); 33 MXCAD. setValue ("LOADCTRLS", 0x02); 34 MXCAD. setValue ("LOADER", strDll); 35 MXCAD. setValue ("MANAGED", 0x01); 36 result ++; 37} 38 catch (Exception ex) 39 {40 if (showMessage) 41 System. windows. forms. messageBox. show (string. format ("error during registration! {0} ", ex. message); 42} 43} 44 45 if (result> 0 & showMessage) 46 System. windows. forms. messageBox. show (string. format ("registration successful! "); 47 return true; 48} 49 catch (Exception ex) 50 {51 52 return false; 53} 54}
Technical contact qq 13712486

Related Article

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.