如何获得Program Files文件夹路径(不是程序文件(x86))从32位WOW的过程? [英] How to get Program Files folder path (not Program Files (x86)) from 32bit WOW process?

查看:3372
本文介绍了如何获得Program Files文件夹路径(不是程序文件(x86))从32位WOW的过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的路径本地(而不是WOW)计划从32位文件目录WOW的过程。

I need to get the path to the native (rather than the WOW) program files directory from a 32bit WOW process.

当我路过CSIDL_PROGRAM_FILES(或CSIDL_PROGRAM_FILESX86)到SHGetSpecialFolderPath它返回的WOW(程序文件(x86))文件夹路径。

When I pass CSIDL_PROGRAM_FILES (or CSIDL_PROGRAM_FILESX86) into SHGetSpecialFolderPath it returns the WOW (Program Files (x86)) folder path.

我preFER避免使用环境变量如果可能的话。

I'd prefer to avoid using an environment variable if possible.

我要比较某些值我从注册表中读取,如果值指向我的应用程序无论是WOW还是原生版本的路径,然后我的code做的东西,如果没有它别的东西。 为了找出其中的本地和WOW我的应用程序的版本预计将我需要的路径为程序文件(x86)和程序文件。

I want to compare some values I read from the registry, if the values point to the path of either the WOW or native version of my app then my code does something, if not it does something else. To figure out where the native and WOW versions of my app are expected to be I need to get the paths to "Program Files (x86)" and "Program Files".

推荐答案

我AP preciate各方面的帮助,尤其是在这个线程的警告。不过,我真的需要这条道路和这个就是我到底得到了它:

I appreciate all the help and, especially, the warnings in this thread. However, I really do need this path and this is how I got it in the end:

(检查删除错误的清晰度,请使用您自己的风险,等等)

(error checking removed for clarity, use at your own risk, etc)

WCHAR szNativeProgramFilesFolder[MAX_PATH];
ExpandEnvironmentStrings(L"%ProgramW6432%", 
                       szNativeProgramFilesFolder, 
                       ARRAYSIZE(szNativeProgramFilesFolder);

这篇关于如何获得Program Files文件夹路径(不是程序文件(x86))从32位WOW的过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆