明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 675|回复: 1

ObjectARX如何打开已知密码的dwg

[复制链接]
发表于 2020-6-22 17:05 | 显示全部楼层 |阅读模式
接触ObjectArx不久,想向大家请教一下,
现在已知dwg的密码,我想通过arx打开它,我查帮助文档,有两个函数是打开文件,分别是AcApDocManager::appContextOpenDocument和AcApDocManager::openDocument,但是都没有接受密码的参数,
我刚刚在论坛里搜了下,有用AutoLISP/Visual LISP 解决的,链接:http://bbs.mjtd.com/forum.php?mo ... hlight=%C3%DC%C2%EB,还有个帖子是.net的,但是没人回复,链接:http://bbs.mjtd.com/forum.php?mo ... hlight=%C3%DC%C2%EB

我想请教一下ObjectArx该如何实现?

发表于 2020-7-2 21:52 | 显示全部楼层
这个很简单啊
AcDbDatabase *pDB->readDWG(const ACHAR *pFileName, _SH_DENYWR,false, password);

移除也很简单
  1. static bool RemovePasswordProtection(AcDbDatabase *pDb)
  2. {
  3.     const SecurityParams *parSecOld = pDb->cloneSecurityParams();
  4.     SecurityParams parSecNew = *parSecOld;
  5.     parSecNew.ulFlags = 0; // Clear all security flags
  6.     return (pDb->setSecurityParams(&parSecNew));
  7. }
  8. // Main function remove password from current drawing
  9. static void PWDRemovePwd(void)
  10. {
  11.     AcDbDatabase *pCurDb  = acdbCurDwg();
  12.     AcApDocument *pCurDoc = curDoc();
  13.     RemovePasswordProtection(pCurDb);
  14.     pCurDb->saveAs(pCurDoc->fileName(),NULL);
  15. }
复制代码

参考https://forums.autodesk.com/t5/o ... -a-dwg/td-p/3427433
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-21 08:52 , Processed in 0.237311 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表