Registry access problem
-
this i used to access information from registry, but the problem is that it prints only first character of the string , instead of whole. void GetProxyServerInfo() { try { HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), 0L, KEY_ALL_ACCESS, &hKey)!=ERROR_SUCCESS) printf("nError opening the desired subkey (doesn't exist?).n"); else { DWORD dwType = REG_SZ; char buf[255] = {0}; DWORD dwBufSize = 255; if( RegQueryValueEx(hKey,TEXT("ProxyServer"),0, &dwType, (LPBYTE)&buf, &dwBufSize) == ERROR_SUCCESS) { //here it prints only single character, not the whole string cout<< buf; } else cout << "can not query for key value\n"; RegCloseKey(hKey); } } catch(char *error) { throw error; } }
“You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
-
this i used to access information from registry, but the problem is that it prints only first character of the string , instead of whole. void GetProxyServerInfo() { try { HKEY hKey; if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), 0L, KEY_ALL_ACCESS, &hKey)!=ERROR_SUCCESS) printf("nError opening the desired subkey (doesn't exist?).n"); else { DWORD dwType = REG_SZ; char buf[255] = {0}; DWORD dwBufSize = 255; if( RegQueryValueEx(hKey,TEXT("ProxyServer"),0, &dwType, (LPBYTE)&buf, &dwBufSize) == ERROR_SUCCESS) { //here it prints only single character, not the whole string cout<< buf; } else cout << "can not query for key value\n"; RegCloseKey(hKey); } } catch(char *error) { throw error; } }
“You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
-
Hello Mogaambo, Is unicode defined? then use
wcout
instead ofcout
. Regards, Jijo._____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
-
i used wcout still the problem exists.
“You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
-
i used wchar_t this and problem solved.
“You will never be a leader unless you first learn to follow and be led.” –Tiorio "Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
It would be better to use TCHAR, so that you are independant of the unicode settings. Take a look at this article[^] for extended information.
Cédric Moonen Software developer
Charting control [v2.0 - Updated] OpenGL game tutorial in C++