Dear Sir,

In WinXP 64bit platform, when I use DeleteFile() function to delete
c:\windows\system32\drivers\a.sys ,it can not be deleted successfully , the
error code is 2(GetLastError ,means can not find the file, but the file is
in the folder),
I guess the system protect the system folder ,then how can I delete the
files in the system folder ?
BTW,I also tried as follows,failed again:
1. I write the hard code of the path
"c:\windows\system32\drivers\a.sys";
2. I use GetSystemWow64Directory () function get the system
directory,message box shows the path is "c:\windows\sysWow64",I use the
return path +"\drivers\a.sys" in DeleteFile() function;
3. I new a A.txt file in system32 folder,use the above two method
to delete the file;
All above 3 methods,GetLastError() return value shows can not find
the special file.

3ks!

Cathy

Re: How to delete system file in WinXP sp2 on AMD 64-Bit platform? by 440gtx

440gtx
Mon Aug 08 05:35:20 CDT 2005

> In WinXP 64bit platform, when I use DeleteFile() function to delete
> c:\windows\system32\drivers\a.sys ,it can not be deleted successfully

You cannot access files in the System32 directory from a Windows 32-bit
application running on 64-bit Windows. The reason is under the covers
the file system is redirecting all your accesses to the SysWOW64 folder
without your knowledge. The best resolution is write a 64-bit
application. Alternatively you can use Wow64DisableWow64FsRedirection
(which by the way does not exist on some early 64-bit Windows versions
and requires care if you want your app to still be able to load under
32-bit Windows). See this Microsoft article:

msdn.microsoft.com/library/default.asp?url=/library/en-us/win64/win64/file_system_redirector.asp