CAD 二次开发 -- 自动加载开发的DLL
发布日期:2021-05-09 09:06:45 浏览次数:23 分类:博客文章

本文共 2872 字,大约阅读时间需要 9 分钟。

CAD���������������������������������DLL���������������������DLL������������������CAD���������

���������������������������������netload ������dll���������CAD���

���������������������������������CAD������������������������������������DLL���

���������������������������������������������������������������������������������dll������������

���������������������������cad���

 

string[] GetRegSubDir(RegistryKey autoCad, string startFlag)

{
string[] subKey = autoCad.GetSubKeyNames();
return subKey.Where(o => o.StartsWith(startFlag)).ToArray();
}

1 //strCadRegKey = "HLD_CAD_Import"; //������������������ ��������������������������������� 2 //strDll dll������������ 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                         //������������������25                         try26                         {27                             Applications.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("������������������{0}", ex.Message));42                     }43                 }44 45                 if (result > 0 && showMessage)46                     System.Windows.Forms.MessageBox.Show(string.Format("���������������"));47                 return true;48             }49             catch (Exception ex)50             {51               52                 return false;53             }54         }

������������������qq 13712486

上一篇:.net 平台下, Socket通讯协议中间件设计思路
下一篇:使用GMap.NET类库,实现地图轨迹回放。(WPF版)

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年04月13日 08时26分27秒