源码如下:
int DelDir(TCHAR *strDir)
{
SHFILEOPSTRUCT shfileopstruct;
shfileopstruct.hwnd = NULL;
shfileopstruct.wFunc = FO_DELETE;
shfileopstruct.pFrom = strDir;
shfileopstruct.pTo = NULL;
shfileopstruct.fFlags = //FOF_SILENT | FOF_NOCONFIRMATION;
shfileopstruct.hNameMappings = NULL;
shfileopstruct.lpszProgressTitle = NULL; return SHFileOperation(&shfileopstruct);
}
int DelDir(TCHAR *strDir)
{
SHFILEOPSTRUCT shfileopstruct;
shfileopstruct.hwnd = NULL;
shfileopstruct.wFunc = FO_DELETE;
shfileopstruct.pFrom = strDir;
shfileopstruct.pTo = NULL;
shfileopstruct.fFlags = //FOF_SILENT | FOF_NOCONFIRMATION;
shfileopstruct.hNameMappings = NULL;
shfileopstruct.lpszProgressTitle = NULL; return SHFileOperation(&shfileopstruct);
}
c:\program files\weds\we-manager professional\mssql$wedskqp3\
http://www.mooremvp.freeserve.co.uk/Win32/w32tip42.htm
for more details ,you can consult this example.
http://codeguru.earthweb.com/files/SHFILEOPSTRUCT.shtml
ID: Q214403
--------------------------------------------------------------------------------
The information in this article applies to:Microsoft Windows 98
Microsoft Windows 95--------------------------------------------------------------------------------
SYMPTOMS
When you delete files or folders in Windows, the files or folders move to the Recycle Bin without any problems. However, when you attempt to empty the Recycle Bin, the following error message may be displayed: File SystemErrors (1026) CAUSE
This behavior occurs because there is not enough disk space on the host drive of a compressed drive to create the Recycled folder. RESOLUTION
To resolve this issue, free some disk space on the host drive to allow Windows to create the Recycled folder. WORKAROUND
To work around this issue: Right-click Recycle Bin, and then click Properties.
Click to select the Do not move files to the Recycle Bin. Remove files immediately when deleted check box, and then click OK.Additional query words: Keywords : kbenv win95 win98
Version : WINDOWS:95
Platform : WINDOWS
Issue type : kbprb
Technology :
Last Reviewed: October 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
Copies, moves, renames, or deletes a file system object. int SHFileOperation(
LPSHFILEOPSTRUCT lpFileOp
);....When used to delete a file, SHFileOperation will attempt to place the deleted file in the Recycle Bin. If you wish to delete a file and guarantee that it will not be placed in the Recycle Bin, use DeleteFile.
意思是说,不能用SHFileOperation不往回收站里删吗?可是我指定成d:\aa.txt时能成功删除而且回收站里也没有.
否则会出错。再次提醒,两个NULL结束!!============================================================================
DocWizard C++ 程序文档生成工具 http://www.betajin.com/alphasun/index.htm
"两个文件名以一个null分开"什么意思,是哪两个文件名,我只用了一个文件名LPCTSTR pFrom.那个LPCTSTR pTo我不用就赋成NULL了.我现在将pFrom设置成
"\"c:\\program files\\weds\\we-manager professional\\mssql$wedskqp3\\\"
然后是:
int i=0;
while (*(strDir+i)=='\0')
i++;
*(strDir+i+1)='\0';
我是说如果打算同时删除俩个或以上文件文件名要用一个null分开.而且可以用"*"通配符。pFrom
Address of a buffer to specify one or more source file names. These names must be fully qualified paths. Standard DOS wild cards, such as "*", are permitted in the file-name position. Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names. Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom. 不过你说在2000下能通过,我想应该不是这问题。而在2000和9x下的区别msdn中只提到2000支持ANSI和Unicode,9x只支持前者。
好好看看msdn.
双Null结尾的字符串,用: sName+='\0'楼主看看是不是有别的原因