Discussion:
why RegQueryValueEx return 2?
(too old to reply)
zhang
2007-03-21 07:15:59 UTC
Permalink
long ret0=(::RegOpenKeyEx(HKEY_CURRENT_USER,data_Set, 0, KEY_READ, &hKey));

ret0 is ERROR_SUCCESS
but next
long ret1::RegQueryValueEx(hKey, "LangType", NULL, &type_1, sType,
&cbData_1);
ret1 is 2
why??
of course I contained the name of the value "LangType"
David Lowndes
2007-03-21 08:29:18 UTC
Permalink
Post by zhang
long ret0=(::RegOpenKeyEx(HKEY_CURRENT_USER,data_Set, 0, KEY_READ, &hKey));
ret0 is ERROR_SUCCESS
but next
long ret1::RegQueryValueEx(hKey, "LangType", NULL, &type_1, sType,
&cbData_1);
ret1 is 2
why??
of course I contained the name of the value "LangType"
What's type_1, sType, and cbData_1? You need to show more of your
code.

Dave
Joseph M. Newcomer
2007-03-21 15:22:50 UTC
Permalink
because whatever key is specified HKCU\<data_Set>\LangType does not exist.

Note that you should have written

::RegQueryValueEx(hKey, _T("LangType"), ...etc..);

Error code 2 is "not found".

While it is not the cause of the error, you have to start assuming that the 'char' data
type is largely obsolete except in rare and exotic situations, of which this is not one.
Program Unicode-aware.

You might want to look at my Registry classes on my MVP Tips site.
joe
Post by zhang
long ret0=(::RegOpenKeyEx(HKEY_CURRENT_USER,data_Set, 0, KEY_READ, &hKey));
ret0 is ERROR_SUCCESS
but next
long ret1::RegQueryValueEx(hKey, "LangType", NULL, &type_1, sType,
&cbData_1);
ret1 is 2
why??
of course I contained the name of the value "LangType"
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
zhang
2007-03-22 01:13:11 UTC
Permalink
Because it is a service and do not have the privilege to access the
HKEY_CURRENT_USER.
Post by zhang
long ret0=(::RegOpenKeyEx(HKEY_CURRENT_USER,data_Set, 0, KEY_READ, &hKey));
ret0 is ERROR_SUCCESS
but next
long ret1::RegQueryValueEx(hKey, "LangType", NULL, &type_1, sType,
&cbData_1);
ret1 is 2
why??
of course I contained the name of the value "LangType"
Loading...