问一下DeleteFolder这个函数的用法(50分)

  • 主题发起人 主题发起人 plf22
  • 开始时间 开始时间
P

plf22

Unregistered / Unconfirmed
GUEST, unregistred user!
我想调用DeleteFolder来删除文件夹,问一下要在uses中引用哪个文件才能调用DeleteFolder
 
摁f1帮助
 
Deletes a subfolder from the given folder.<br>从一个已经给的目录下 删除 一个子目录。
 
请查阅msdn的IMAPIFolder:IMAPIContainer和IMAPIFolder::DeleteFolder栏目;<br>delphi没有直接定义此函数,但是定义了IMAPIFolder接口,<br>你可以使用IMAPIFolder接口(com)来调用此函数(准确的讲叫方法)。<br>接口定义在delphi目录下的ocx/servers/OutlookX.pas中(x是版本号,d6中为8)。
 
试过了,但是还是不能调用DeleteFolder这个函数,再次请教各位
 
Platform SDK: MAPI <br>IMAPIFolder::DeleteFolder<br>The IMAPIFolder::DeleteFolder method removes a subfolder.<br><br>Quick Info<br>See IMAPIFolder : IMAPIContainer.<br><br>HRESULT DeleteFolder(<br>&nbsp; ULONG cbEntryID, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; LPENTRYID lpEntryID, &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; ULONG ulUIParam, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; LPMAPIPROGRESS lpProgress, &nbsp; <br>&nbsp; ULONG ulFlags &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>);<br>&nbsp;<br>Parameters<br>cbEntryID <br>[in] Count of bytes in the entry identifier pointed to by the lpEntryID parameter. <br>lpEntryID <br>[in] Pointer to the entry identifier of the subfolder to delete. <br>ulUIParam <br>[in] Handle of the parent window for the progress indicator. The ulUIParam parameter is ignored unless the FOLDER_DIALOG flag is set in the ulFlags parameter. <br>lpProgress <br>[in] Pointer to a progress object for displaying a progress indicator. If NULL is passed in lpProgress, the message store provider displays a progress indicator using the MAPI progress object implementation. The lpProgress parameter is ignored unless the FOLDER_DIALOG flag is set in ulFlags. <br>ulFlags <br>[in] Bitmask of flags that controls the deletion of the subfolder. The following flags can be set: <br>DEL_FOLDERS <br>All subfolders of the subfolder pointed to by lpEntryID should be deleted. <br>DEL_MESSAGES <br>All messages in the subfolder pointed to by lpEntryID should be deleted. <br>FOLDER_DIALOG <br>A progress indicator should be displayed while the operation proceeds. <br>Return Values<br>S_OK <br>The specified folder has been successfully deleted. <br>MAPI_E_HAS_FOLDERS <br>The subfolder being deleted contains subfolders, and the DEL_FOLDERS flag was not set. The subfolder was not deleted. <br>MAPI_E_HAS_MESSAGES <br>The subfolder being deleted contains messages, and the DEL_MESSAGES flag was not set. The subfolder was not deleted. <br>MAPI_W_PARTIAL_COMPLETION <br>The call succeeded, but not all of the entries were successfully deleted. When this warning is returned, the call should be handled as successful. To test for this warning, use the HR_FAILED macro. See Using Macros for Error Handling. <br>Remarks<br>The IMAPIFolder::DeleteFolder method deletes a subfolder. Folders to be deleted must be located in the folder designated as the special wastebasket folder, typically the Deleted Items folder in the IPM subtree. By default, DeleteFolder only operates on empty folders, but it can be used successfully on non-empty folders by setting two flags: DEL_FOLDERS and DEL_MESSAGES. Only empty folders or folders that set both the DEL_FOLDERS and DEL_MESSAGES flags on the DeleteFolder call can be deleted. DEL_FOLDERS enables all of the folder's subfolders to be removed; DEL_MESSAGES enables all of the folder's messages to be removed.<br><br>Notes to Implementers<br>When the delete operation involves more than one folder, perform the operation as completely as possible for each folder. Sometimes one of the folders to be deleted does not exist or has been moved or copied elsewhere. Do not stop the operation prematurely unless a failure occurs that is beyond your control, such as running out of memory, running out of disk space, or corruption in the message store.<br><br>During a DeleteFolder call, messages being processed by the MAPI spooler are not deleted; they are left in their parent folders. Do not call the IMsgStore::AbortSubmit method for these messages. <br><br>Notes to Callers<br>Expect these return values under the following conditions:<br><br>Condition Return value <br>DeleteFolder has successfully deleted every message and subfolder. S_OK <br>DeleteFolder was unable to successfully delete every message and subfolder. MAPI_W_PARTIAL_COMPLETION or MAPI_E_NOT_FOUND <br>DeleteFolder was unable to complete. Any error value except MAPI_E_NOT_FOUND <br><br><br>When DeleteFolder is unable to complete, do not assume that no work was done. DeleteFolder might have been able to delete one or more of the messages and subfolders before encountering the error. <br><br>If one or more subfolders cannot be deleted, DeleteFolder returns MAPI_W_PARTIAL_COMPLETION or MAPI_E_NOT_FOUND, depending on the message store provider's implementation. <br><br>&amp;copy; 1996-2000 Microsoft Corporation. All rights reserved.Built on Tuesday, May 09, 2000
 
to 太阳火:<br>&nbsp; &nbsp;这篇文档我也看到了,就是不会调用它,有没有一点源码来提示我一下
 
RemoveDir<br><br>Unit<br><br>SysUtils<br><br>function RemoveDir(const Dir: string): Boolean;
 
to 老人家:<br>功能不够强,只能做到Deletes an existing empty directory.,我要能删除文件夹,<br>还要包括文件夹里面的内容一起删除。<br><br>
 
那你找其他的吧
 
期待高手出现!
 
You Can Use a recursion ;
 
to 人在昆明<br>&nbsp; &nbsp;那太麻烦了,我要删除的文件夹下面文件和目录比较多,我要deltree的效果
 
procedure CleanFollder(strSrcDir: string);<br>var<br>&nbsp; sr : TSearchRec;<br>&nbsp; iErrno, FAttr : integer;<br>&nbsp; strFerryPath :string;<br>begin<br>&nbsp; if strSrcDir[Length(strSrcDir)]&lt;&gt;'/' then<br>&nbsp; &nbsp; strSrcDir := strSrcDir + '/';<br>&nbsp; //目录属性<br>&nbsp; FAttr := faAnyFile xor $8;<br>&nbsp; //查找所有文件以及目录<br>&nbsp; if FindFirst(strSrcDir+'*.*', FAttr, sr)=0 then<br>&nbsp; begin<br>&nbsp; &nbsp; repeat<br>&nbsp; //是文件就先删除<br>&nbsp; &nbsp; &nbsp; if sr.Attr&lt;&gt;faDirectory then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; DeleteFile(strSrcDir+sr.Name);<br>&nbsp; &nbsp; &nbsp; &nbsp; continue;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; //特殊的文件目录,不处理<br>&nbsp; &nbsp; &nbsp; if((sr.Name='.')or(sr. Name='..'))then continue;<br>&nbsp; //递归删除子目录<br>&nbsp; &nbsp; &nbsp; CleanFollder(strSrcDir+sr.Name);<br>&nbsp; &nbsp; until FindNext(sr)&lt;&gt;0;<br>&nbsp; &nbsp; FindClose(sr);<br>&nbsp; end;<br>&nbsp; if strSrcDir&lt;&gt;strFerryPath then<br>&nbsp; begin<br>&nbsp; //这里就是删除目录:)<br>&nbsp; &nbsp; RmDir(strSrcDir);<br>&nbsp; &nbsp; iErrno := IOResult;<br>&nbsp; //如果失败了,呵呵<br>&nbsp; &nbsp; if iErrno &lt;&gt; 0 then<br>&nbsp; &nbsp; &nbsp; MessageDlg('Cannot remove directory! '+char(13)+'ErrorNo: '+<br>&nbsp; &nbsp; &nbsp; &nbsp; inttostr(iErrno), mtWarning, [mbOk], 0);<br>&nbsp; end;<br>end;<br><br>You Can Call The Procedure Such As:<br>&nbsp; &nbsp;CleanFollder('D:/aaaaa'); &nbsp; <br>Compile And Test Successful In Win2k<br>You Can Try And Give Me All The Points <br>OH **** It's Only 50 Points.<br>
 
to 人在昆明:<br>&nbsp; &nbsp;你这方法老早就有了,我主要想看如何能调用DeleteFolder,写的这么辛苦,只能说声谢谢了!
 
没有必要这么用吧,一直都用 人在昆明这样的用法<br>那个函数还不是这样调的?<br><br>use MAPI?[:(]
 
接受答案了.
 
后退
顶部