获取Win32注册表值 [英] Get win32 registry value
本文介绍了获取Win32注册表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何解析
How can we parse
RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SYSTEM\\CurrentControlSet\\Enum\\BTHENUM\\{00001101-0000-1000-8000-00805f9b34fb}_LOCALMFG&000f\\9&3408FE52&0&646E6C00E02E_C00000000\\Device Parameters", 0, KEY_QUERY_VALUE, &hKey) )
这样我们就可以将其用于每个GUID(将可用的guid遍历到DeviceParameters)
SYSTEM \\ CurrentControlSet \\ Enum \\ BTHENUM \\ [GUID1 ... x] \\ [Somenumber] \\ DeviceParameters
目前,我能够针对单个硬编码的GUID值执行此操作,但是GUID可能因计算机而异,因此我想使其成为动态GUID解析.
so that we can use it for each GUID (traversing available guid to DeviceParameters )
SYSTEM\\CurrentControlSet\\Enum\\BTHENUM\\[GUID1...x]\\[Somenumber]\\DeviceParameters
Currently i am able to do it for single hard coded GUID value but GUID may differ machine to machine so i want to make it dynamic GUID parsing.
LPCTSTR const lpValueName = L"PortName";
HKEY hKey = NULL;
if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SYSTEM\\CurrentControlSet\\Enum\\BTHENUM\\{00001101-0000-1000-8000-00805f9b34fb}_LOCALMFG&000f\\9&3408FE52&0&646E6C00E02E_C00000000\\Device Parameters", 0, KEY_QUERY_VALUE, &hKey) )
return 1;
DWORD dwDataType = 0;
LPBYTE lpValue = NULL;
RegQueryValueEx( hKey,
lpValueName,
0,
&dwDataType,
lpValue, // NULL
&dwSize); // will contain the data size
// Alloc the buffer
lpValue = (LPBYTE)malloc(dwSize);
// Call twice RegQueryValueEx to get the value
int lRet = RegQueryValueEx(hKey,
lpValueName,
0,
&dwDataType,
lpValue,
&dwSize);
RegCloseKey(hKey);
在此先感谢:)
Thanks in advance :)
推荐答案
看一下有关如何遍历注册表的示例的链接:
http://msdn.microsoft.com/en-us/library/df4afx57.aspx [ ^ ]
http://www.codeguru.com/cpp/wp/system/registry/article. php/c5671 [ ^ ]
祝你好运!
Have a look at the links with some examples of how to traverse the registry:
http://msdn.microsoft.com/en-us/library/df4afx57.aspx[^]
http://www.codeguru.com/cpp/w-p/system/registry/article.php/c5671[^]
Good luck!
使用 RegEnumKeyEx [ ^ ] ,以及其他任何枚举功能来查找您感兴趣的元素.
Use RegEnumKeyEx[^], and any of the other enumeration functions to find the elements that you are interested in.
这篇关于获取Win32注册表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文