问题描述
我用C#打开不带密码的WORD和带密码的WORD。如果对上了就正常了。如果密码错误或者有问题就无法清除内存的WORD进程,另外会弹出个输入密码的输入框,请问如何操作,谢谢,分全部送上。两个问题,打开代码如何写,完整的,第二,如果密码错误了的时候,怎么写代码清理进程并且不要弹出那个框让人手工输入密码。Q52572818联系我给分。再次感谢!ObjectfileName=strFileName;ObjectconfirmConversions=false;ObjectreadOnly=System.Reflection.Missing.Value;ObjectaddToRecentFiles=false;ObjectpasswordDocument=strPWD;ObjectpasswordTemplate="";Objectrevert=true;ObjectwritePasswordDocument="";ObjectwritePasswordTemplate="";Objectformat=System.Reflection.Missing.Value;Objectencoding=System.Text.Encoding.UTF8;Objectvisible=false;ObjectopenConflictDocument=true;ObjectopenAndRepair=false;ObjectdocumentDirection=false;ObjectnoEncodingDialog=true;ObjectxmlTransform=System.Reflection.Missing.Value;System.TypewordType=System.Type.GetTypeFromProgID("Word.Application");dynamicwordApp=System.Activator.CreateInstance(wordType,false);dynamicwordDoc=null;wordApp.Visible=false;//不显示窗口try{wordDoc=wordApp.Documents.Open(reffileName,refconfirmConversions,refreadOnly,refaddToRecentFiles,refpasswordDocument,refpasswordTemplate,refrevert,refwritePasswordDocument,refwritePasswordTemplate,refformat,refencoding,refvisible);wordDoc.Close();wordApp.Quit();}catch(ExceptionexDoc){MessageBox.Show("打开失败"+exDoc.Message);}wordDoc=null;wordApp=null;