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


C++ DeleteFileW函数代码示例

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


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

示例1: fal_unlink

bool fal_unlink( const String &filename, int32 &fsStatus )
{
   String fname = filename;
   Path::uriToWin( fname );

   AutoWString wBuffer( fname );
   BOOL res = DeleteFileW( wBuffer.w_str() );
	if( ! res && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED )
	{
      AutoCString cBuffer( fname );
      res = DeleteFile( cBuffer.c_str() );
	}

   if ( res == TRUE ) {
      return true;
   }
   fsStatus = GetLastError();
   return false;
}
开发者ID:Klaim,项目名称:falcon,代码行数:19,代码来源:dir_sys_win.cpp

示例2: file_copy_using_memory_map

/**
* @brief
* @param
* @see
* @remarks
* @code
* @endcode
* @return
**/
bool
file_copy_using_memory_map(
_In_ const wchar_t* src_file,
_In_ const wchar_t* dst_file
)
{
	_ASSERTE(NULL != src_file);
	_ASSERTE(NULL != dst_file);
	if (NULL == src_file || NULL == dst_file) return false;

	if (!is_file_existsW(src_file))
	{
		print("err ] no src file = %ws", src_file);
		return false;
	}

	if (is_file_existsW(dst_file))
	{
		DeleteFileW(dst_file);
	}

	// map src, dst file
	pmap_context src_ctx = open_map_context(src_file);
	pmap_context dst_ctx = create_map_context(dst_file, src_ctx->size);
	if (NULL == src_ctx || NULL == dst_ctx)
	{
		print("err ] open_map_context() failed.");
		close_map_context(src_ctx);
		close_map_context(dst_ctx);
		return false;
	}

	// copy src to dst by mmio
	for (uint32_t i = 0; i < src_ctx->size; ++i)
	{
		dst_ctx->view[i] = src_ctx->view[i];
	}

	close_map_context(src_ctx);
	close_map_context(dst_ctx);
	
	return true;
}
开发者ID:cshwan96,项目名称:BOB4_OS2,代码行数:52,代码来源:150714+OS.cpp

示例3: delete_unique

static bool delete_unique(const char *path, const bool dir)
{
	bool err;

	UTF16_ENCODE(path);

	if (dir) {
		err = !RemoveDirectoryW(path_16);
		if (err) printf("Unable to remove directory");
	}
	else {
		err = !DeleteFileW(path_16);
		if (err) callLocalErrorCallBack("Unable to delete file");
	}

	UTF16_UN_ENCODE(path);

	return err;
}
开发者ID:linkedinyou,项目名称:blender-git,代码行数:19,代码来源:fileops.c

示例4: main

int main(int argc, char *argv[])
{
  WCHAR  src[4] = {'f', 'o', 'o', '\0'};
  WCHAR dest[4] = {'b', 'a', 'r', '\0'};
  WCHAR  dir[5] = {'/', 't', 'm', 'p', '\0'};
  HANDLE h;
  unsigned int b;

  PAL_Initialize(argc, (const char**)argv);
  SetCurrentDirectoryW(dir);
  SetCurrentDirectoryW(dir);
  h =  CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL);
  WriteFile(h, "Testing\n", 8, &b, FALSE);
  CloseHandle(h);
  CopyFileW(src, dest, FALSE);
  DeleteFileW(src);
  PAL_Terminate();
  return 0;
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:19,代码来源:example1.c

示例5: iop_rmfile

int
iop_rmfile(io_args_t *const args)
{
	const char *const path = args->arg1.path;

	uint64_t size;
	int result;

	ioeta_update(args->estim, path, path, 0, 0);

	size = get_file_size(path);

#ifndef _WIN32
	result = unlink(path);
	if(result != 0)
	{
		(void)ioe_errlst_append(&args->result.errors, path, errno, strerror(errno));
	}
#else
	{
		wchar_t *const utf16_path = utf8_to_utf16(path);
		const DWORD attributes = GetFileAttributesW(utf16_path);
		if(attributes & FILE_ATTRIBUTE_READONLY)
		{
			SetFileAttributesW(utf16_path, attributes & ~FILE_ATTRIBUTE_READONLY);
		}
		result = !DeleteFileW(utf16_path);

		if(result)
		{
			/* FIXME: use real system error message here. */
			(void)ioe_errlst_append(&args->result.errors, path, IO_ERR_UNKNOWN,
					"Directory removal failed");
		}

		free(utf16_path);
	}
#endif

	ioeta_update(args->estim, NULL, NULL, 1, size);

	return result;
}
开发者ID:dennishamester,项目名称:vifm,代码行数:43,代码来源:iop.c

示例6: GetFileAttributesW

        void WinNode::remove_impl(const std::string& name)
        {
            std::wstring nativePath = m_nativePath + L"\\" + win32::multiByteToWideChar(name);

            DWORD dw = GetFileAttributesW(nativePath.c_str());
            if (dw == INVALID_FILE_ATTRIBUTES)
                return win32::ThrowLastError("WinNode::remove_impl: '%s'", name.c_str());

            if (dw & FILE_ATTRIBUTE_DIRECTORY)
            {
                if (!RemoveDirectoryW(nativePath.c_str()))
                    win32::ThrowLastError("WinNode::remove_impl: '%s'", name.c_str());
            }
            else
            {
                if (!DeleteFileW(nativePath.c_str()))
                    win32::ThrowLastError("WinNode::remove_impl: '%s'", name.c_str());
            }
        }
开发者ID:kona4kona,项目名称:HiME_,代码行数:19,代码来源:hime-fs-winfs.cpp

示例7: ucmRegisterAndRunTarget

/*
* ucmRegisterAndRunTarget
*
* Purpose:
*
* Register shim database and execute target app.
*
*/
BOOL ucmRegisterAndRunTarget(
	_In_ LPWSTR lpSystemDirectory,
	_In_ LPWSTR lpSdbinstPath,
	_In_ LPWSTR lpShimDbPath,
	_In_ LPWSTR lpTarget,
	_In_ BOOL IsPatch
	)
{
	BOOL bResult = FALSE;
	WCHAR szTempDirectory[MAX_PATH * 2];
	WCHAR szCmd[MAX_PATH * 4];

	if ((lpTarget == NULL) ||
		(lpSystemDirectory == NULL)  ||
		(lpSdbinstPath == NULL) ||
		(lpShimDbPath == NULL)
		)
	{
		return bResult;
	}

	RtlSecureZeroMemory(szCmd, sizeof(szCmd));
	if (IsPatch) {
		wsprintf(szCmd, L"-p %ws", lpShimDbPath);
	}
	else {
		_strcpy_w(szCmd, lpShimDbPath);
	}

	//register shim, sdbinst.exe
	if (supRunProcess(lpSdbinstPath, szCmd)) {
		RtlSecureZeroMemory(szTempDirectory, sizeof(szTempDirectory));
		wsprintfW(szTempDirectory, lpTarget, lpSystemDirectory);
		bResult = supRunProcess(szTempDirectory, NULL);

		//remove database
		RtlSecureZeroMemory(szCmd, sizeof(szCmd));
		wsprintf(szCmd, L"/q /u %ws", lpShimDbPath);
		supRunProcess(lpSdbinstPath, szCmd);
		DeleteFileW(lpShimDbPath);
	}
	return bResult;
}
开发者ID:1872892142,项目名称:UACME,代码行数:51,代码来源:gootkit.c

示例8: clean_up

static void clean_up(void)
{
    if(tmp_file != INVALID_HANDLE_VALUE)
        CloseHandle(tmp_file);

    if(tmp_file_name) {
        DeleteFileW(tmp_file_name);
        heap_free(tmp_file_name);
        tmp_file_name = NULL;
    }

    if(tmp_file != INVALID_HANDLE_VALUE) {
        CloseHandle(tmp_file);
        tmp_file = INVALID_HANDLE_VALUE;
    }

    if(install_dialog)
        EndDialog(install_dialog, 0);
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:19,代码来源:install.c

示例9: CoCreateInstance

HRESULT CMediaFileList::AddVideoFile(BSTR FilePath, IMediaFile **ppResult)
{
	HRESULT hr = CoCreateInstance(CLSID_MediaFile, NULL, 
							  CLSCTX_INPROC_SERVER, 
							  IID_IMediaFile, 
							  (void **)ppResult);

	if (FAILED(hr) || *ppResult == NULL)
		return E_POINTER;
	
	(*ppResult)->AddRef();
	(*ppResult)->put_FilePath(FilePath);
	
	CComBSTR strPosterPath;
	double dDuration = 0;
	hr = GetFileInfo(FilePath, 0, &dDuration, 0, 0, 0, 0, 0, &strPosterPath);
	
	if (SUCCEEDED(hr))
	{
		(*ppResult)->put_Duration(dDuration);
	}
	
	(*ppResult)->put_PosterFramePath(strPosterPath);
	(*ppResult)->put_StartOffset(GetCurrentVideoLength());

	if (dDuration == 0.0)
	{
		(*ppResult)->put_IsImage(VARIANT_TRUE);
		(*ppResult)->put_Duration(7);
	}
	else
		(*ppResult)->put_IsImage(VARIANT_FALSE);

//	USES_CONVERSION;
	DeleteFileW(strPosterPath);

	m_videoList.AddTail(*ppResult);
	
	(*ppResult)->AddRef();

	return S_OK;
}
开发者ID:BlackMael,项目名称:DirectEncode,代码行数:42,代码来源:MediaFileList.cpp

示例10: __win_fs_rename

/*
 * __win_fs_rename --
 *	Rename a file.
 */
static int
__win_fs_rename(WT_FILE_SYSTEM *file_system,
    WT_SESSION *wt_session, const char *from, const char *to, uint32_t flags)
{
	DWORD windows_error;
	WT_DECL_RET;
	WT_DECL_ITEM(from_wide);
	WT_DECL_ITEM(to_wide);
	WT_SESSION_IMPL *session;

	WT_UNUSED(file_system);
	WT_UNUSED(flags);
	session = (WT_SESSION_IMPL *)wt_session;

	WT_ERR(__wt_to_utf16_string(session, from, &from_wide));
	WT_ERR(__wt_to_utf16_string(session, to, &to_wide));

	/*
	 * Check if file exists since Windows does not override the file if
	 * it exists.
	 */
	if (GetFileAttributesW(to_wide->data) != INVALID_FILE_ATTRIBUTES)
		if (DeleteFileW(to_wide->data) == FALSE) {
			windows_error = __wt_getlasterror();
			__wt_errx(session,
			    "%s: file-rename: DeleteFileW: %s",
			    to, __wt_formatmessage(session, windows_error));
			WT_ERR(__wt_map_windows_error(windows_error));
		}

	if (MoveFileW(from_wide->data, to_wide->data) == FALSE) {
		windows_error = __wt_getlasterror();
		__wt_errx(session,
		    "%s to %s: file-rename: MoveFileW: %s",
		    from, to, __wt_formatmessage(session, windows_error));
		WT_ERR(__wt_map_windows_error(windows_error));
	}

err:	__wt_scr_free(session, &from_wide);
	__wt_scr_free(session, &to_wide);
	return (ret);
}
开发者ID:Machyne,项目名称:mongo,代码行数:46,代码来源:os_fs.c

示例11: GameStatisticsMgrImpl_RemoveGameStatistics

static HRESULT STDMETHODCALLTYPE GameStatisticsMgrImpl_RemoveGameStatistics(
        IGameStatisticsMgr* iface,
        LPCWSTR GDFBinaryPath)
{
    HRESULT hr;
    WCHAR lpApplicationId[49];
    WCHAR sStatsFile[MAX_PATH];

    TRACE("(%p, %s)\n", iface, debugstr_w(GDFBinaryPath));

    hr = GAMEUX_getAppIdFromGDFPath(GDFBinaryPath, lpApplicationId);

    if(SUCCEEDED(hr))
        hr = GAMEUX_buildStatisticsFilePath(lpApplicationId, sStatsFile);

    if(SUCCEEDED(hr))
        hr = (DeleteFileW(sStatsFile)==TRUE ? S_OK : HRESULT_FROM_WIN32(GetLastError()));

    return hr;
}
开发者ID:miurahr,项目名称:wine,代码行数:20,代码来源:gamestatistics.c

示例12: OnClearRecentItems

VOID OnClearRecentItems()
{
   WCHAR szPath[MAX_PATH], szFile[MAX_PATH];
   WIN32_FIND_DATA info;
   HANDLE hPath;

    if(SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_RECENT, NULL, 0, szPath)))
    {
        StringCchPrintf(szFile,MAX_PATH, L"%s\\*.*", szPath);
        hPath = FindFirstFileW(szFile, &info);
        do
        {
            StringCchPrintf(szFile,MAX_PATH, L"%s\\%s", szPath, info.cFileName);
            DeleteFileW(szFile);

        }while(FindNextFileW(hPath, &info));
        FindClose(hPath);
        /* FIXME: Disable the button*/
    }
}
开发者ID:Strongc,项目名称:reactos,代码行数:20,代码来源:startmnucust.cpp

示例13: wxRemoveFile

//---------------------------------------------------------------------------
bool File::Delete(const Ztring &File_Name)
{
    #ifdef ZENLIB_USEWX
        return wxRemoveFile(File_Name.c_str());
    #else //ZENLIB_USEWX
        #ifdef ZENLIB_STANDARD
            #ifdef UNICODE
                return unlink(File_Name.To_Local().c_str())==0;
            #else
                return unlink(File_Name.c_str())==0;
            #endif //UNICODE
        #elif defined WINDOWS
            #ifdef UNICODE
                return DeleteFileW(File_Name.c_str())!=0;
            #else
                return DeleteFile(File_Name.c_str())!=0;
            #endif //UNICODE
        #endif
    #endif //ZENLIB_USEWX
}
开发者ID:Armada651,项目名称:mpc-hc,代码行数:21,代码来源:File.cpp

示例14: MSTASK_ITaskScheduler_Delete

static HRESULT WINAPI MSTASK_ITaskScheduler_Delete(ITaskScheduler *iface, LPCWSTR name)
{
    static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
    static const WCHAR jobW[] = { '.','j','o','b',0 };
    WCHAR task_name[MAX_PATH];

    TRACE("%p, %s\n", iface, debugstr_w(name));

    if (strchrW(name, '.')) return E_INVALIDARG;

    GetWindowsDirectoryW(task_name, MAX_PATH);
    lstrcatW(task_name, tasksW);
    lstrcatW(task_name, name);
    lstrcatW(task_name, jobW);

    if (!DeleteFileW(task_name))
        return HRESULT_FROM_WIN32(GetLastError());

    return S_OK;
}
开发者ID:wine-mirror,项目名称:wine,代码行数:20,代码来源:task_scheduler.c

示例15: install_from_cache

static enum install_res install_from_cache(void)
{
    WCHAR *cache_file_name;
    enum install_res res;

    cache_file_name = get_cache_file_name(FALSE);
    if(!cache_file_name)
        return INSTALL_NEXT;

    if(!sha_check(cache_file_name)) {
        WARN("could not validate checksum\n");
        DeleteFileW(cache_file_name);
        heap_free(cache_file_name);
        return INSTALL_NEXT;
    }

    res = install_file(cache_file_name);
    heap_free(cache_file_name);
    return res;
}
开发者ID:iXit,项目名称:wine,代码行数:20,代码来源:addons.c


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