I use COM to open an encrypted file in ARX. but I failed when I pass the parameter of password into the function. The AutoCAD still ask for the password when I run it. Why?
the code is:
CAcadApplication IApp;
CAcadDocuments IDocs;
CAcadDocument IDoc;
IDispatch *pDisp = acedGetAcadWinApp()->GetIDispatch(TRUE); //AddRef is called on the pointer
IApp.AttachDispatch(pDisp); // does not call AddRef()
IApp.put_Visible(true);
// Get the Documents collection
pDisp = IApp.get_Documents();
IDocs.AttachDispatch(pDisp);
pDisp = IApp.get_ActiveDocument(); //AddRef is called
IDoc.AttachDispatch(pDisp);
CString fullPath = "c:\\test2.dwg";
VARIANT vReadOnly;
VariantInit(&vReadOnly);
V_VT(&vReadOnly) = VT_BOOL;
V_BOOL(&vReadOnly) = VARIANT_TRUE;
CString pwd = "123";
VARIANT vPwd;
VariantInit(&vPwd);
V_VT(&vPwd) = VT_BSTR;
V_BSTR(&vPwd) = pwd.AllocSysString();
// Open it for Read-Only
IDoc = IDocs.Open(fullPath, vReadOnly, vPwd);