已赞1
已收藏0
分享

使用.net在中望CAD中设置环境变量

Acad做法

在AutoCAD中,我们一般采用PInvoke的方式设置环境变量,因为官方没有给.net提供设置环境变量的API

[DllImport("accore.dll", CharSet = CharSet.Auto,
    CallingConvention = CallingConvention.Cdecl,EntryPoint = "acedSetEnv")]
private static extern int AcedSetEnv(string? envName, StringBuilder newValue);

中望CAD做法

中望cad的程序集在zwcad.exe,通过导出PE入口点可以发现,中望的入口和Acad是差不多的,EntryPoint为zcedSetEnv,但是直接改EntryPoint调用发现无法生效

解决方案是,手动指定CharSet = CharSet.Unicode

[DllImport("zwcad.exe", CharSet = CharSet.Unicode,
    CallingConvention = CallingConvention.Cdecl, EntryPoint = "zcedSetEnv")]
private static extern int AcedSetEnv(string? envName, StringBuilder newValue);

完

0 条评论 A文章作者 M管理员
    暂无讨论,说说你的看法吧
❯
购物车
优惠劵
今日签到
有新私信 私信列表
搜索
复制链接
微信扫码
已复制到剪贴板