通过搜索注册表来获取应用程序路径

来源:互联网 发布:微表情图解软件 编辑:程序博客网 时间:2024/05/22 14:17

/*Function: get the specified value of regedit key

_strKey: Pointer to a null-terminated string containing the name of the subkey to open

_strValue: Pointer to a null-terminated string containing the name of the value to query

Return : Pointer to a buffer that receives the value's data.

This parameter can be NULL if the data is not required

*/

CString CMainFrame::GetRetailPath(CString _strKey, CString _strValue)

{

HKEY hKey;

TCHAR szSupplyPath[256];

DWORD dwBufferLen = 256;

LONG lRet;

 

_strKey,

0,

KEY_QUERY_VALUE,

&hKey) != ERROR_SUCCESS)

lRet = ::RegQueryValueEx(hKey,

_strValue,

NULL,

NULL,

(LPBYTE)szSupplyPath,

&dwBufferLen);

RegCloseKey(hKey);

 

}

if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE,return _T("");return szSupplyPath;
原创粉丝点击