Why copying to system32 automatically copies to sysWOW64 instead?

后端 未结 3 1178
傲寒
傲寒 2021-01-18 12:11

I\'m trying to copy a file to C:\\windows\\system32 by calling CopyFileA - debugging shows that indeed the string \"C:\\windows\\system32\\filename\" is sent to CopyFileA, b

3条回答
  •  感动是毒
    2021-01-18 12:18

    Simply if you want to check the operating system then check it and access the folder system32 is like:

    string os = Environment.GetEnvironmentVariable("WINDIR") + "\\SysWOW64";
                if (Directory.Exists(os))
                {
                    destinationDir = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "sysnative\\");
            }
    

    By this you can copy the file in system32 folder.

    Enjoy: Ali Raza

提交回复
热议问题