943,516 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 6078
  • C++ RSS
May 7th, 2004
0

Question regarding reading from registry (Win32) VC6

Expand Post »
I'm working on an aim profiler program in C++ using VC6, and
I'm trying to take the last login name for AIM from the registry and store it in a variable. I'm not that experienced with the Win32 Api, but I'm trying. Here's my code: (I took it off a code example site, then butchered it for my needs, which is most likely why it doesn't work)

C++ Syntax (Toggle Plain Text)
  1.  
  2. HKEY hKey;
  3. REG_SZ dwSize = "";
  4. REG_SZ dwDataType = "";
  5. REG_SZ dwValue = "";
  6.  
  7. if(::RegOpenKeyEx(HKEY_CURRENT_USER,
  8. "Software\\America Online\\AOL Instant Messenger\\CurrentVersion\\Login",
  9. 0,
  10. KEY_QUERY_VALUE,
  11. &hKey) == ERROR_SUCCESS)
  12. {
  13. //Get Last Login Name from opened Key
  14. if(::RegQueryValueEx(hKey,
  15. "Screen Name",
  16. 0,
  17. &dwDataType,
  18. &dwValue,
  19. &dwSize) != ERROR_SUCCESS)
  20. {
  21. // Close key
  22. ::RegCloseKey(hKey);
  23. }
  24.  
  25. // Close key
  26. ::RegCloseKey(hKey);
  27. }

These are my includes, which I'm not sure about either

C++ Syntax (Toggle Plain Text)
  1.  
  2. #include "stdafx.h"
  3. #include "conio.h"
  4. #include "fstream.h"
  5. #include "stdio.h"
  6. #include "iostream"
  7. #include "cstdlib"
  8. #include "windows.h"
  9. #include "winreg.h"

it gives me a bunch of error about undeclared identifiers in the top 4 lines and it also says:

"error C2440: '=' : cannot convert from 'char [1]' to 'int' This conversion requires a reinterpret_cast, a C-style cast or function-style cast"

for the top 4 lines.

I'm probably doing a lot wrong, but hopefully someone can tell me what I need to do. If you look in regedit at "Software\\America Online\\AOL Instant Messenger\\CurrentVersion\\Login" you'll see the key that says "Screen Name" and then the last login, I want that last login screename in a variable.
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Caps is offline Offline
5 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Function that returns void
Next Thread in C++ Forum Timeline: How do you write a code which compiles in c but not in c++?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC