Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winapi 远程计算机上程序文件的路径_Winapi - Fatal编程技术网

Winapi 远程计算机上程序文件的路径

Winapi 远程计算机上程序文件的路径,winapi,Winapi,如何确定远程计算机上“程序文件”目录的(本地)路径?任何版本的SHGetFolderPath(或相关函数)都不会将远程计算机的名称作为参数 我想我可以尝试使用远程注册表查询HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir,但我希望有一种“文档化”的方法。许多标准路径需要用户登录,特别是“shell”(即资源管理器)提供的SH*函数。我想你要想找到正确的路径,唯一的办法就是像你刚才提到的那样通过注册表。这就是我最后所做的:

如何确定远程计算机上“程序文件”目录的(本地)路径?任何版本的SHGetFolderPath(或相关函数)都不会将远程计算机的名称作为参数


我想我可以尝试使用远程注册表查询HKLM\Software\Microsoft\Windows\CurrentVersion\ProgramFilesDir,但我希望有一种“文档化”的方法。许多标准路径需要用户登录,特别是“shell”(即资源管理器)提供的SH*函数。我想你要想找到正确的路径,唯一的办法就是像你刚才提到的那样通过注册表。

这就是我最后所做的:(PSZ计算机的格式必须是“\\name”。nPath是pszPath的大小(以TCHARs为单位))

DWORD GetProgramFilesDir(PCTSTR pszComputer、PTSTR pszPath、DWORD&nPath)
{
德沃德n;
HKEY hHKLM;
if((n=RegConnectRegistry(pszComputer、HKEY\u LOCAL\u MACHINE和hHKLM))==ERROR\u SUCCESS)
{
香港教育学院;
如果((n=RegOpenKeyEx(hHKLM,_T(“软件\\Microsoft\\Windows\\CurrentVersion”),0,键读取,&hWin))==ERROR\u SUCCESS)
{
DWORD nType,cbPath=nPath*sizeof(TCHAR);
n=regqueryvaluex(hWin,_T(“ProgramFilesDir”)、NULL,&nType、reinterpret_cast(pszPath)和cbPath);
nPath=cbPath/sizeof(TCHAR);
RegCloseKey(hWin);
}
RegCloseKey(hHKLM);
}
返回n;
}
DWORD GetProgramFilesDir(PCTSTR pszComputer, PTSTR pszPath, DWORD& nPath) 
{
    DWORD n;
    HKEY hHKLM;
    if ((n = RegConnectRegistry(pszComputer, HKEY_LOCAL_MACHINE, &hHKLM)) == ERROR_SUCCESS)
    {
        HKEY hWin;
        if ((n = RegOpenKeyEx(hHKLM, _T("Software\\Microsoft\\Windows\\CurrentVersion"), 0, KEY_READ, &hWin)) == ERROR_SUCCESS)
        {
            DWORD nType, cbPath = nPath * sizeof(TCHAR);
            n = RegQueryValueEx(hWin, _T("ProgramFilesDir"), NULL, &nType, reinterpret_cast<PBYTE>(pszPath), &cbPath);
            nPath = cbPath / sizeof(TCHAR);
            RegCloseKey(hWin);
        }
        RegCloseKey(hHKLM);
    }
    return n;
}