⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notifyshell.cpp

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 CPP
字号:
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.

	$Id: notifyshell.cpp,v 1.2 2002/10/17 20:50:07 wjb Exp $
____________________________________________________________________________*/

#include "windows.h"
#include "shlobj.h"
#include "notifyshell.h"

#define FLUSHTYPE SHCNF_FLUSHNOWAIT

extern "C" BOOL NotifyShellRename(char *szOld,char *szNew)
{
	if(MoveFile(szOld,szNew))
	{
		SHChangeNotify(SHCNE_RENAMEITEM,SHCNF_PATH|FLUSHTYPE,
			szOld,szNew);
		return TRUE;
	}

	return FALSE;
}

extern "C" BOOL NotifyShellOperation(char *szPath,DWORD dwOperation)
{
	LPITEMIDLIST pidl;
	LPSHELLFOLDER pDesktopFolder;
	OLECHAR       olePath[MAX_PATH];
	ULONG         chEaten;
	ULONG         dwAttributes;
	LPMALLOC		 pMalloc;
	BOOL			 bRst;

	bRst=FALSE;

	// 
	// Get a pointer to the Desktop's IShellFolder interface.
	// 
	if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder)))
	{
		if (SUCCEEDED(SHGetMalloc(&pMalloc)))
		{
			// 
			// IShellFolder::ParseDisplayName requires the file name be in
			// Unicode.
			// 
			MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szPath, -1,
							   olePath, MAX_PATH);

			// 
			// Convert the path to an ITEMIDLIST.
			// 
			if(SUCCEEDED(pDesktopFolder->ParseDisplayName(
														 NULL,
														 NULL,
														 olePath,
														 &chEaten,
														 &pidl,
														 &dwAttributes)))
			{
				if(pidl!=NULL)
				{
					switch(dwOperation)
					{
						case PGPNS_DELETE:
							if(DeleteFile( szPath ))
							{
								SHChangeNotify(SHCNE_DELETE,SHCNF_IDLIST|FLUSHTYPE,
									pidl,NULL);
								bRst=TRUE;
							}
							break;

						case PGPNS_FORCEDELNOTIFY:
							bRst=TRUE;
							SHChangeNotify(SHCNE_DELETE,SHCNF_IDLIST|FLUSHTYPE,
								pidl,NULL);
							break;
					}
		
					// 
					// pidl now contains a pointer to an ITEMIDLIST for .\readme.txt.
					// This ITEMIDLIST needs to be freed using the IMalloc allocator
					// returned from SHGetMalloc().
					// 
					pMalloc->Free(pidl);
				}
			}

			pMalloc->Release();
		}

		pDesktopFolder->Release();
	}

	if(!bRst)
	{
		switch(dwOperation)
		{
			case PGPNS_DELETE:
				DeleteFile( szPath ); // Delete it anyway
				break;
		}
	}

	return bRst;
}


/*__Editor_settings____

	Local Variables:
	tab-width: 4
	End:
	vi: ts=4 sw=4
	vim: si
_____________________*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -