这篇教程C++ DeleteFileW函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DeleteFileW函数的典型用法代码示例。如果您正苦于以下问题:C++ DeleteFileW函数的具体用法?C++ DeleteFileW怎么用?C++ DeleteFileW使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DeleteFileW函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fal_unlinkbool 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,
示例2: file_copy_using_memory_map/*** @brief* @param* @see* @remarks* @code* @endcode* @return**/boolfile_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,
示例3: delete_uniquestatic 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,
示例4: mainint 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,
示例5: iop_rmfileintiop_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,
示例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,
示例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,
示例8: clean_upstatic 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,
示例9: CoCreateInstanceHRESULT 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,
示例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,
示例11: GameStatisticsMgrImpl_RemoveGameStatisticsstatic 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,
示例12: OnClearRecentItemsVOID 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,
示例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,
示例14: MSTASK_ITaskScheduler_Deletestatic 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,
示例15: install_from_cachestatic 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,
示例16: RTDECLRTDECL(int) RTSymlinkDelete(const char *pszSymlink, uint32_t fDelete){ /* * Convert the path. */ PRTUTF16 pwszNativeSymlink; int rc = RTStrToUtf16(pszSymlink, &pwszNativeSymlink); if (RT_SUCCESS(rc)) { /* * We have to use different APIs depending on whether this is a * directory or file link. This means we're subject to one more race * than on posix at the moment. We could probably avoid this though, * if we wanted to go talk with the native API layer below Win32... */ DWORD dwAttr = GetFileAttributesW(pwszNativeSymlink); if (dwAttr != INVALID_FILE_ATTRIBUTES) { if (dwAttr & FILE_ATTRIBUTE_REPARSE_POINT) { BOOL fRc; if (dwAttr & FILE_ATTRIBUTE_DIRECTORY) fRc = RemoveDirectoryW(pwszNativeSymlink); else fRc = DeleteFileW(pwszNativeSymlink); if (fRc) rc = VINF_SUCCESS; else rc = RTErrConvertFromWin32(GetLastError()); } else rc = VERR_NOT_SYMLINK; } else rc = RTErrConvertFromWin32(GetLastError()); RTUtf16Free(pwszNativeSymlink); } LogFlow(("RTSymlinkDelete(%p={%s}, %#x): returns %Rrc/n", pszSymlink, pszSymlink, fDelete, rc)); return rc;}
开发者ID:mutoso-mirrors,项目名称:vbox,代码行数:41,
示例17: dbsave//database functionsvoid dbsave(){ dprintf("Saving database..."); DWORD ticks = GetTickCount(); JSON root = json_object(); CommentCacheSave(root); LabelCacheSave(root); BookmarkCacheSave(root); FunctionCacheSave(root); LoopCacheSave(root); BpCacheSave(root); WString wdbpath = StringUtils::Utf8ToUtf16(dbpath); if(json_object_size(root)) { Handle hFile = CreateFileW(wdbpath.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); if(!hFile) { dputs("/nFailed to open database for writing!"); json_decref(root); //free root return; } SetEndOfFile(hFile); char* jsonText = json_dumps(root, JSON_INDENT(4)); DWORD written = 0; if(!WriteFile(hFile, jsonText, (DWORD)strlen(jsonText), &written, 0)) { json_free(jsonText); dputs("/nFailed to write database file!"); json_decref(root); //free root return; } hFile.Close(); json_free(jsonText); if(!settingboolget("Engine", "DisableDatabaseCompression")) LZ4_compress_fileW(wdbpath.c_str(), wdbpath.c_str()); } else //remove database when nothing is in there DeleteFileW(wdbpath.c_str()); dprintf("%ums/n", GetTickCount() - ticks); json_decref(root); //free root}
开发者ID:kifast,项目名称:x64dbg,代码行数:42,
示例18: file_delete/** file_delete : string -> void <doc>Delete the file. Exception on error.</doc>**/static value file_delete( value path ) { #if defined(EPPC) || defined(KORE_CONSOLE) return alloc_bool(true); #else val_check(path,string); #ifdef NEKO_WINDOWS const wchar_t* _path = val_wstring(path); gc_enter_blocking(); if( DeleteFileW(_path) != 0 ) #else gc_enter_blocking(); if( unlink(val_string(path)) != 0 ) #endif { gc_exit_blocking(); return alloc_null(); } gc_exit_blocking(); return alloc_bool(true); #endif}
开发者ID:KTXSoftware,项目名称:khacpp,代码行数:25,
示例19: mktempdirchar*mktempdir(void){ WinRune buf[1024]; WinRune tmp[MAX_PATH]; WinRune golink[] = {'g', 'o', 'l', 'i', 'n', 'k', '/0'}; int n; n = GetTempPathW(nelem(buf), buf); if(n <= 0) return nil; buf[n] = '/0'; if(GetTempFileNameW(buf, golink, 0, tmp) == 0) return nil; DeleteFileW(tmp); if(!CreateDirectoryW(tmp, nil)) return nil; return toutf(tmp);}
开发者ID:8l,项目名称:go,代码行数:21,
示例20: Delete Yuni::IO::Error Delete(const AnyString& filename) { // DeleteFile is actually a macro and will be replaced by DeleteFileW // with Visual Studio. Consequently we can not use the word DeleteFile..... if (filename.empty()) return Yuni::IO::errUnknown; # ifndef YUNI_OS_WINDOWS return (unlink(filename.c_str())) ? Yuni::IO::errUnknown : Yuni::IO::errNone; # else const char* const p = filename.c_str(); uint len = filename.size(); if (p[len - 1] == '//' or p[len - 1] == '/') --len; // Driver letters if (len == 2 and p[1] == ':') return Yuni::IO::errBadFilename; String norm; Yuni::IO::Normalize(norm, AnyString(p, len)); // Conversion into wchar_t WString wstr(norm, true); if (wstr.empty()) return Yuni::IO::errUnknown; wstr.replace('/', '//'); return (DeleteFileW(wstr.c_str())) ? Yuni::IO::errNone : Yuni::IO::errUnknown; # endif }
开发者ID:libyuni,项目名称:libyuni,代码行数:40,
示例21: DeleteFolderBOOL DeleteFolder(LPCWSTR path, DELFOLDER_PROGRESS_PROC proc, PVOID context){ std::vector<std::wstring> file_list; if (!EnumFileList(path, L"*", file_list, TRUE, FALSE)) { return FALSE; } ULONG attributes = 0; ULONG current_index = 0; ULONG total = file_list.size(); for (std::vector<std::wstring>::iterator it = file_list.begin(); it != file_list.end(); ++it) { if (proc != NULL) { if (!proc(it->c_str(), total, ++current_index, context)) { continue; } } attributes = GetFileAttributesW(it->c_str()); if (attributes == INVALID_FILE_ATTRIBUTES) { return FALSE; } if (attributes & FILE_ATTRIBUTE_DIRECTORY) { SetFileAttributesW(it->c_str(), FILE_ATTRIBUTE_NORMAL); if (!DeleteFolder(it->c_str(), proc, context)) { return FALSE; } } else { SetFileAttributesW(it->c_str(), FILE_ATTRIBUTE_NORMAL); if (!DeleteFileW(it->c_str())) { return FALSE; } } } return RemoveDirectoryW(path);}
开发者ID:0cch,项目名称:misc,代码行数:39,
示例22: ucmWusaExtractPackage/** ucmWusaExtractPackage** Purpose:** Extract cab to protected directory using wusa.**/BOOL ucmWusaExtractPackage( LPWSTR lpCommandLine ){ BOOL bResult = FALSE; WCHAR szMsuFileName[MAX_PATH * 2]; WCHAR szCmd[MAX_PATH * 4]; RtlSecureZeroMemory(szMsuFileName, sizeof(szMsuFileName)); _strcpy(szMsuFileName, g_ctx.szTempDirectory); _strcat(szMsuFileName, ELLOCNAK_MSU); //extract msu data to target directory RtlSecureZeroMemory(szCmd, sizeof(szCmd)); wsprintfW(szCmd, lpCommandLine, szMsuFileName); bResult = supRunProcess(L"cmd.exe", szCmd); if (szMsuFileName[0] != 0) { DeleteFileW(szMsuFileName); } return bResult;}
开发者ID:spnow,项目名称:UACME,代码行数:30,
示例23: winClosestatic int winClose(OsFile **pId){ winFile *pFile; int rc = 1; if( pId && (pFile = (winFile*)*pId)!=0 ){ int rc, cnt = 0; TRACE2("CLOSE %d/n", pFile->h); do{ rc = CloseHandle(pFile->h); }while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );#if OS_WINCE winceDestroyLock(pFile); if( pFile->zDeleteOnClose ){ DeleteFileW(pFile->zDeleteOnClose); sqliteFree(pFile->zDeleteOnClose); }#endif OpenCounter(-1); sqliteFree(pFile); *pId = 0; } return rc ? SQLITE_OK : SQLITE_IOERR;}
开发者ID:bazhenovc,项目名称:nebula3,代码行数:22,
示例24: create_fake_dll/*********************************************************************** * create_fake_dll */BOOL create_fake_dll( const WCHAR *name, const WCHAR *source ){ HANDLE h; HMODULE module; BOOL ret; /* first check for an existing file */ h = CreateFileW( name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL ); if (h != INVALID_HANDLE_VALUE) { if (!is_fake_dll( h )) { TRACE( "%s is not a fake dll, not overwriting it/n", debugstr_w(name) ); CloseHandle( h ); return TRUE; } /* truncate the file */ SetFilePointer( h, 0, NULL, FILE_BEGIN ); SetEndOfFile( h ); } else { h = CreateFileW( name, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL ); if (h == INVALID_HANDLE_VALUE) { WARN( "failed to create %s/n", debugstr_w(name) ); return FALSE; } } module = LoadLibraryW( source ); ret = build_fake_dll( h, module ); CloseHandle( h ); if (module) FreeLibrary( module ); if (!ret) DeleteFileW( name ); return ret;}
开发者ID:howard5888,项目名称:wineT,代码行数:42,
示例25: download_procstatic DWORD WINAPI download_proc(PVOID arg){ WCHAR tmp_dir[MAX_PATH], tmp_file[MAX_PATH]; HRESULT hres; GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir); GetTempFileNameW(tmp_dir, NULL, 0, tmp_file); TRACE("using temp file %s/n", debugstr_w(tmp_file)); hres = URLDownloadToFileW(NULL, url, tmp_file, 0, &InstallCallback); if(FAILED(hres)) { ERR("URLDownloadToFile failed: %08x/n", hres); return 0; } if(sha_check(tmp_file)) install_file(tmp_file); DeleteFileW(tmp_file); EndDialog(install_dialog, 0); return 0;}
开发者ID:YokoZar,项目名称:wine,代码行数:22,
示例26: exec_rename_doteststatic void exec_rename_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout){ void *memfs = memfs_start_ex(Flags, FileInfoTimeout); WCHAR FilePath[MAX_PATH], File2Path[MAX_PATH], File3Path[MAX_PATH]; HANDLE Process; HANDLE Handle; StringCbPrintfW(FilePath, sizeof FilePath, L"%s%s//helper.exe", Prefix ? L"" : L"////?//GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs)); StringCbPrintfW(File2Path, sizeof File2Path, L"%s%s//helper2.exe", Prefix ? L"" : L"////?//GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs)); StringCbPrintfW(File3Path, sizeof File3Path, L"%s%s//helper3.exe", Prefix ? L"" : L"////?//GLOBALROOT", Prefix ? Prefix : memfs_volumename(memfs)); Handle = CreateFileW(File3Path, FILE_WRITE_DATA, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); ASSERT(INVALID_HANDLE_VALUE != Handle); CloseHandle(Handle); ExecHelper(FilePath, 1000, &Process); ASSERT(MoveFileExW(FilePath, File2Path, MOVEFILE_REPLACE_EXISTING)); ASSERT(MoveFileExW(File2Path, FilePath, MOVEFILE_REPLACE_EXISTING)); ASSERT(!MoveFileExW(File3Path, FilePath, MOVEFILE_REPLACE_EXISTING)); ASSERT(ERROR_ACCESS_DENIED == GetLastError()); WaitHelper(Process, 1000); ASSERT(MoveFileExW(File3Path, FilePath, MOVEFILE_REPLACE_EXISTING)); ASSERT(DeleteFileW(FilePath)); memfs_stop(memfs);}
开发者ID:billziss-gh,项目名称:winfsp,代码行数:39,
示例27: create_manifeststatic BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const xmlstr_t *key, const xmlstr_t *version, const xmlstr_t *lang, const void *data, DWORD len ){ static const WCHAR winsxsW[] = {'w','i','n','s','x','s','//','m','a','n','i','f','e','s','t','s','//'}; static const WCHAR extensionW[] = {'.','m','a','n','i','f','e','s','t',0}; WCHAR *path; DWORD pos, written, path_len; HANDLE handle; BOOL ret = FALSE; path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + sizeof(winsxsW)/sizeof(WCHAR) + arch->len + name->len + key->len + version->len + 18 + sizeof(extensionW)/sizeof(WCHAR); path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) ); pos = GetWindowsDirectoryW( path, MAX_PATH ); path[pos++] = '//'; memcpy( path + pos, winsxsW, sizeof(winsxsW) ); pos += sizeof(winsxsW) / sizeof(WCHAR); get_manifest_filename( arch, name, key, version, lang, path + pos, MAX_PATH - pos ); strcatW( path + pos, extensionW ); handle = CreateFileW( path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL ); if (handle == INVALID_HANDLE_VALUE && GetLastError() == ERROR_PATH_NOT_FOUND) { create_directories( path ); handle = CreateFileW( path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL ); } if (handle != INVALID_HANDLE_VALUE) { TRACE( "creating %s/n", debugstr_w(path) ); ret = (WriteFile( handle, data, len, &written, NULL ) && written == len); if (!ret) ERR( "failed to write to %s (error=%u)/n", debugstr_w(path), GetLastError() ); CloseHandle( handle ); if (!ret) DeleteFileW( path ); } HeapFree( GetProcessHeap(), 0, path ); return ret;}
开发者ID:AlexSteel,项目名称:wine,代码行数:38,
示例28: create_winsxs_dllstatic BOOL create_winsxs_dll( const WCHAR *dll_name, const xmlstr_t *arch, const xmlstr_t *name, const xmlstr_t *key, const xmlstr_t *version, const xmlstr_t *lang, const void *dll_data, size_t dll_size ){ static const WCHAR winsxsW[] = {'w','i','n','s','x','s','//'}; WCHAR *path; const WCHAR *filename; DWORD pos, written, path_len; HANDLE handle; BOOL ret = FALSE; if (!(filename = strrchrW( dll_name, '//' ))) filename = dll_name; else filename++; path_len = GetWindowsDirectoryW( NULL, 0 ) + 1 + sizeof(winsxsW)/sizeof(WCHAR) + arch->len + name->len + key->len + version->len + 18 + strlenW( filename ) + 1; path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) ); pos = GetWindowsDirectoryW( path, path_len ); path[pos++] = '//'; memcpy( path + pos, winsxsW, sizeof(winsxsW) ); pos += sizeof(winsxsW) / sizeof(WCHAR); get_manifest_filename( arch, name, key, version, lang, path + pos, path_len - pos ); pos += strlenW( path + pos ); path[pos++] = '//'; strcpyW( path + pos, filename ); handle = create_dest_file( path ); if (handle && handle != INVALID_HANDLE_VALUE) { TRACE( "creating %s/n", debugstr_w(path) ); ret = (WriteFile( handle, dll_data, dll_size, &written, NULL ) && written == dll_size); if (!ret) ERR( "failed to write to %s (error=%u)/n", debugstr_w(path), GetLastError() ); CloseHandle( handle ); if (!ret) DeleteFileW( path ); } HeapFree( GetProcessHeap(), 0, path ); return ret;}
开发者ID:AlexSteel,项目名称:wine,代码行数:38,
示例29: InitializeSetupActionLogBOOL WINAPIInitializeSetupActionLog (BOOL bDeleteOldLogFile){ WCHAR szFileName[MAX_PATH]; GetWindowsDirectoryW(szFileName, MAX_PATH); if (szFileName[wcslen(szFileName)] != L'//') { wcsncat(szFileName, L"//", (sizeof(szFileName) / sizeof(szFileName[0])) - wcslen(szFileName)); } wcsncat(szFileName, L"setuplog.txt", (sizeof(szFileName) / sizeof(szFileName[0])) - wcslen(szFileName)); if (bDeleteOldLogFile) { SetFileAttributesW(szFileName, FILE_ATTRIBUTE_NORMAL); DeleteFileW(szFileName); } hLogFile = CreateFileW(szFileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hLogFile == INVALID_HANDLE_VALUE) { hLogFile = NULL; return FALSE; } return TRUE;}
开发者ID:hoangduit,项目名称:reactos,代码行数:38,
注:本文中的DeleteFileW函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ DeleteInstanceFromDB函数代码示例 C++ DeleteFileA函数代码示例 |