C++ 複製檔案到C:\windows\system32\失敗問題
阿新 • • 發佈:2019-02-20
程式是32位的,在64位系統下,所有對system32的操作都會被轉向syswow64
方法一
程式編譯成x64位
方法二
關閉重定向
if( Wow64EnableWow64FsRedirection(FALSE) ) { // Any function calls in this block of code should be as concise // and as simple as possible to avoid unintended results. CopyFile(_T("CherryTrail\\AP6212\\x64\\43430r0nvram.txt"), _T("C:\\Windows\\System32\\drivers\\43430r0nvram.txt"), FALSE); // Immediately re-enable redirection. Note that any resources // associated with OldValue are cleaned up by this call. if ( FALSE == Wow64EnableWow64FsRedirection(TRUE) ) { // Failure to re-enable redirection should be considered // a criticial failure and execution aborted. return; } }