当前位置: 首页>>代码示例>>C++>>正文


C++ SHFileOperation函数代码示例

本文整理汇总了C++中SHFileOperation函数的典型用法代码示例。如果您正苦于以下问题:C++ SHFileOperation函数的具体用法?C++ SHFileOperation怎么用?C++ SHFileOperation使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SHFileOperation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DeleteDirectory

static bool DeleteDirectory(const std::string& dir)
{
	// SHFileOperation requires file names to be terminated with two \0s
	std::string tmpDir = dir + std::string(1, '\0');

	SHFILEOPSTRUCT fop;
	fop.wFunc = FO_DELETE;
	fop.pFrom = tmpDir.c_str();
	fop.fFlags = FOF_NO_UI;

	return (SHFileOperation(&fop) == 0);
}
开发者ID:Napsty,项目名称:icinga2,代码行数:12,代码来源:icinga-installer.cpp

示例2: log_webfiles_init

void log_webfiles_init ()
{
	TCHAR tszPath [MAX_PATH] = _T ("");
	GetTempPath (MAX_PATH, tszPath);
	_tcscat (tszPath, _T ("\\fdmflvsniff"));

	SHFILEOPSTRUCT sfos = {0};
	sfos.wFunc = FO_DELETE;
	sfos.pFrom = tszPath;
	sfos.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
	SHFileOperation (&sfos);
}
开发者ID:DragonZX,项目名称:fdm2,代码行数:12,代码来源:AppWinSockSniffDll.cpp

示例3: op_removesl

static int
op_removesl(void *data, const char *src, const char *dst)
{
#ifndef _WIN32
	char *escaped;
	char cmd[16 + PATH_MAX];
	int result;

	escaped = escape_filename(src, 0);
	if(escaped == NULL)
		return -1;

	snprintf(cmd, sizeof(cmd), "rm -rf %s", escaped);
	LOG_INFO_MSG("Running rm command: \"%s\"", cmd);
	result = background_and_wait_for_errors(cmd);

	free(escaped);
	return result;
#else
	if(is_dir(src))
	{
		char buf[PATH_MAX];
		int err;
		int i;
		snprintf(buf, sizeof(buf), "%s%c", src, '\0');
		for(i = 0; buf[i] != '\0'; i++)
			if(buf[i] == '/')
				buf[i] = '\\';
		SHFILEOPSTRUCTA fo = {
			.hwnd = NULL,
			.wFunc = FO_DELETE,
			.pFrom = buf,
			.pTo = NULL,
			.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI,
		};
		err = SHFileOperation(&fo);
		log_msg("Error: %d", err);
		return err;
	}
	else
	{
		int ok;
		DWORD attributes = GetFileAttributesA(src);
		if(attributes & FILE_ATTRIBUTE_READONLY)
			SetFileAttributesA(src, attributes & ~FILE_ATTRIBUTE_READONLY);
		ok = DeleteFile(src);
		if(!ok)
			LOG_WERROR(GetLastError());
		return !ok;
	}
#endif
}
开发者ID:ackeack,项目名称:workenv,代码行数:52,代码来源:ops.c

示例4: wxT

void FileActionThread::DoFileAction(FileAction action, const wxArrayString& sources, const wxString& targetDir, bool allowUndo) { //static
	if (sources.empty()) return;

#ifdef __WXMSW__

	// Paths have to be double-null terminated
	wxString filePaths;
	for (unsigned int i = 0; i < sources.GetCount(); ++i) {
		filePaths += sources[i] + wxT('\0');
	}
	const wxString target = targetDir + wxT('\0');

	// The File Operation Structure
	SHFILEOPSTRUCT SHFileOp;
	ZeroMemory(&SHFileOp, sizeof(SHFILEOPSTRUCT));
	SHFileOp.hwnd = NULL;
	SHFileOp.pFrom = filePaths.c_str();
	SHFileOp.fFlags = FOF_NOCONFIRMMKDIR;
	if (allowUndo) SHFileOp.fFlags |= FOF_ALLOWUNDO;

	switch (action) {
	case FILEACTION_DELETE:
		SHFileOp.wFunc = FO_DELETE;
		break;

	case FILEACTION_DELETE_SILENT:
		SHFileOp.wFunc = FO_DELETE;
		SHFileOp.fFlags |= FOF_SILENT|FOF_NOCONFIRMATION|FOF_NOERRORUI;
		break;

	case FILEACTION_COPY:
		SHFileOp.wFunc = FO_COPY;
		SHFileOp.pTo = target.c_str();
		break;

	case FILEACTION_MOVE:
		SHFileOp.wFunc = FO_MOVE;
		SHFileOp.pTo = target.c_str();
		break;

	default:
		wxASSERT(false);
		return;
	}

	// Do the file operation
	SHFileOperation(&SHFileOp);

#endif //__WXMSW__

	return;
}
开发者ID:BBkBlade,项目名称:e,代码行数:52,代码来源:FileActionThread.cpp

示例5: DeleteFolder

int DeleteFolder(std::wstring path) {
  if (path.back() == '\\')
    path.pop_back();

  path.push_back('\0');

  SHFILEOPSTRUCT fos = {0};
  fos.wFunc = FO_DELETE;
  fos.pFrom = path.c_str();
  fos.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;

  return SHFileOperation(&fos);
}
开发者ID:Hydro8182,项目名称:taiga,代码行数:13,代码来源:file.cpp

示例6: EmptyFolder

void EmptyFolder()
{
	SHFILEOPSTRUCT file_op = {
		NULL,
		FO_DELETE,
		tszRoot,
		_T(""),
		FOF_NOERRORUI | FOF_SILENT | FOF_NOCONFIRMATION,
		false,
		0,
		_T("") };
	SHFileOperation(&file_op);
}
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:13,代码来源:Events.cpp

示例7: DeleteViaShell

bool CTGitPathList::DeleteViaShell(LPCTSTR path, bool bTrash, bool bShowErrorUI)
{
	SHFILEOPSTRUCT shop = {0};
	shop.wFunc = FO_DELETE;
	shop.pFrom = path;
	shop.fFlags = FOF_NOCONFIRMATION|FOF_NO_CONNECTED_ELEMENTS;
	if (!bShowErrorUI)
		shop.fFlags |= FOF_NOERRORUI | FOF_SILENT;
	if (bTrash)
		shop.fFlags |= FOF_ALLOWUNDO;
	const bool bRet = (SHFileOperation(&shop) == 0);
	return bRet;
}
开发者ID:iamduyu,项目名称:TortoiseGit,代码行数:13,代码来源:TGitPath.cpp

示例8: WinMain

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd, SW_HIDE);
    SHFILEOPSTRUCT sh;
    sh.wFunc  = FO_DELETE;
    sh.pFrom  = L"d:\\1\2\0";
    sh.pTo    = NULL;
    sh.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
    sh.hNameMappings = 0;
    sh.lpszProgressTitle = NULL;
    SHFileOperation (&sh);
}
开发者ID:temakonkin,项目名称:Ufo_Kill,代码行数:13,代码来源:main.cpp

示例9: ZeroMemory

void CTreeFileCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) 
{
	TV_DISPINFO* pDispInfo = (TV_DISPINFO*)pNMHDR;
  if (pDispInfo->item.pszText)
  {
    SHFILEOPSTRUCT shfo;
    ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
    shfo.hwnd = AfxGetMainWnd()->GetSafeHwnd();
    shfo.wFunc = FO_RENAME;
    shfo.fFlags = FOF_ALLOWUNDO;

    CString sFrom = ItemToPath(pDispInfo->item.hItem);
    int nFromLength = sFrom.GetLength();
    TCHAR* pszFrom = new TCHAR[nFromLength + 2];
    _tcscpy(pszFrom, sFrom);
    pszFrom[nFromLength+1] = _T('\0');
    shfo.pFrom = pszFrom;
    HTREEITEM hParent = GetParentItem(pDispInfo->item.hItem);
    CString sParent = ItemToPath(hParent);
    CString sTo;
    if (IsDrive(sParent))
      sTo = sParent + pDispInfo->item.pszText;
    else
      sTo = sParent + _T("\\") + pDispInfo->item.pszText;

    int nToLength = _tcslen(sTo);
    TCHAR* pszTo = new TCHAR[nToLength + 2];
    _tcscpy(pszTo, sTo);
    pszTo[nToLength+1] = _T('\0');
    shfo.pTo = pszTo;

    //Let the shell perform the actual rename
    if (SHFileOperation(&shfo) == 0 && shfo.fAnyOperationsAborted == FALSE)
    {
      *pResult = TRUE;

      //Update its text  
      SetItemText(pDispInfo->item.hItem, pDispInfo->item.pszText);

      //Also update the icons for it
      CString sPath = ItemToPath(pDispInfo->item.hItem);
      SetItemImage(pDispInfo->item.hItem, GetIconIndex(sPath), GetSelIconIndex(sPath));
    }

    //Don't forget to free up the memory we allocated
    delete [] pszFrom;
    delete [] pszTo;
  }
	
	*pResult = 0;
}
开发者ID:5432935,项目名称:genesis3d,代码行数:51,代码来源:FileTreeCtrl.cpp

示例10: DeletetoRecycle

void DeletetoRecycle(char * FN)
{
#ifdef WIN32
	SHFILEOPSTRUCT FileOp;

	FileOp.hwnd = NULL;
	FileOp.wFunc = FO_DELETE;
	FileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR | FOF_ALLOWUNDO;
	FileOp.pFrom = FN;
	FileOp.pTo = NULL;

	SHFileOperation(&FileOp);
#endif
}
开发者ID:g8bpq,项目名称:LinBPQ,代码行数:14,代码来源:Housekeeping.c

示例11: SHFileOperation

	bool FileSystem::FolderCopy(const String& from, const String& to) const
	{
		if (!IsFolderExist(from) || !IsFolderExist(to))
			return false;

		SHFILEOPSTRUCT s = { 0 };
		s.hwnd = o2Application.mHWnd;
		s.wFunc = FO_COPY;
		s.fFlags = FOF_SILENT;
		s.pTo = to;
		s.pFrom = from;
		auto res = SHFileOperation(&s);
		return res == 0;
	}
开发者ID:zenkovich,项目名称:o2,代码行数:14,代码来源:FileSystemImpl.cpp

示例12: Rename

// Rename pszOldName to pszNewName.
// support File or Directory. Rename(_T("C:\\DirOld"), _T("C:\\DirNew"));
bool  CFileOps_i::Rename(LPCTSTR pszOldName, LPCTSTR pszNewName)
{
  SHFILEOPSTRUCT FileOp = {0, };
    
  FileOp.wFunc = FO_RENAME;
  FileOp.pFrom = (LPCTSTR)pszOldName; 
  FileOp.pTo   = (LPCTSTR)pszNewName; 
  FileOp.fFlags = (FILEOP_FLAGS)(FOF_SILENT|FOF_NOCONFIRMATION);
      
  if(SHFileOperation(&FileOp) == 0) // if will not be placed in the Recycle Bin, use DeleteFile. 
    return TRUE;
  else
    return FALSE;
}
开发者ID:fre2003,项目名称:l3220,代码行数:16,代码来源:FileOperations_20.cpp

示例13: DeleteViaShell

bool CTSVNPathList::DeleteViaShell(LPCTSTR path, bool bTrash, HWND hErrorWnd)
{
    SHFILEOPSTRUCT shop = {0};
    shop.hwnd = hErrorWnd;
    shop.wFunc = FO_DELETE;
    shop.pFrom = path;
    shop.fFlags = FOF_NOCONFIRMATION|FOF_SILENT|FOF_NO_CONNECTED_ELEMENTS;
    if (hErrorWnd == NULL)
        shop.fFlags |= FOF_NOERRORUI;
    if (bTrash)
        shop.fFlags |= FOF_ALLOWUNDO;
    const bool bRet = (SHFileOperation(&shop) == 0);
    return bRet;
}
开发者ID:yuexiaoyun,项目名称:tortoisesvn,代码行数:14,代码来源:TSVNPath.cpp

示例14: ET_STRING_TO_PARAM_TYPE

bool et::removeDirectory(const std::string& name)
{
	ET_STRING_TYPE aName = ET_STRING_TO_PARAM_TYPE(name);
	aName.resize(aName.size() + 1);
	aName.back() = 0;

	SHFILEOPSTRUCT fop = { };

	fop.wFunc = FO_DELETE;
	fop.pFrom = aName.c_str();
	fop.fFlags = FOF_NO_UI;

	return SHFileOperation(&fop) == 0;
}
开发者ID:Loki7979,项目名称:et-engine,代码行数:14,代码来源:tools.win.cpp

示例15: CopyDirectory

static bool CopyDirectory(const std::string& source, const std::string& destination)
{
	// SHFileOperation requires file names to be terminated with two \0s
	std::string tmpSource = source + std::string(1, '\0');
	std::string tmpDestination = destination + std::string(1, '\0');

	SHFILEOPSTRUCT fop;
	fop.wFunc = FO_COPY;
	fop.pFrom = tmpSource.c_str();
	fop.pTo = tmpDestination.c_str();
	fop.fFlags = FOF_NO_UI;

	return (SHFileOperation(&fop) == 0);
}
开发者ID:b0e,项目名称:icinga2,代码行数:14,代码来源:icinga-installer.cpp


注:本文中的SHFileOperation函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。