我创建了一个WPF窗口中出现了很多按钮,他们每个人运行不同的程序。为了运行微软的Word,比如说,我用的:
I've created a WPF Window with a lot of buttons, each of them run a different program. To run MS Word, for instance, I used:
System.Diagnostics.Process.Start("C:\\Program Files (x86)\\Microsoft Office\\Office14\\WINWORD.EXE");
但是,当我尝试运行Windows 7的截图工具同样的方式就行不通。它应该是这样的:
But when I try to run the Windows 7 Snipping Tool the same way it doesn't work. It was supposed to be like this:
System.Diagnostics.Process.Start("C:\\Windows\\System32\\SnippingTool.exe");
我敢肯定的路径是正确的,但总是出现一则消息说,该文件未找到。我想知道为什么会这样。
I'm sure the path is correct, but always appears a message saying the file wasn't found. I would like to know why is this happening.
重要提示:我使用的是Windows 7 64位
Important: I use Windows 7 64 bits.
推荐答案使用这样的:
// if the build platform of this app is x86 use C:\windows\sysnative if(!Environment.Is64BitProcess) System.Diagnostics.Process.Start("C:\\Windows\\sysnative\\SnippingTool.exe"); else System.Diagnostics.Process.Start("C:\\Windows\\system32\\SnippingTool.exe");问题是在构建平台(86)和文件夹 C:\Windows\System32\ 64位OS'es
The problem is in your build platform (x86) and the automatic redirection of the folder C:\Windows\System32\ on 64-bit OS'es.
基本上,有几个原因,在Vista / Windows 7的64位OS'es当32位应用程序试图访问 C:\Windows\System32\ 将被自动重定向到名为文件夹 C:\Windows\SysWOW64\ 。因此,你不能启动 snippingtool.exe ,因为它不存在的文件夹中。
Basically, for several reasons, in vista/windows 7 64-bit OS'es when a 32 bit application try to access to C:\Windows\System32\ it is automatically redirected to the folder called C:\Windows\SysWOW64\. Hence, you cannot start snippingtool.exe because it is not present in that folder.
的唯一方法是使用 C:\Windows\sysnative\ 并绕过重定向
The only way is to use C:\Windows\sysnative\ and bypass the redirection.
更多推荐
为什么我不能运行从WPF的截图工具?
发布评论