Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Enumerating Registry

This topic is 5546 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm having a slight problem with the RegEnumEx function and actually displaying the Folder names.
#include <windows.h>
#include <iostream>
using namespace std;

int main() {
	HKEY RegKey;
	char achKey[80];
	if (r==ERROR_SUCCESS) {
		int err = 0;
		int i = 0;
		int counter = 0;
		DWORD maxPath = MAX_PATH;

		while (err==ERROR_SUCCESS || err == ERROR_MORE_DATA) {
			err = RegEnumKeyEx(RegKey, i, achKey, &maxPath, NULL, NULL, NULL, NULL); 
			if (err != ERROR_NO_MORE_ITEMS) {
				cout << achKey << endl;
	}else {
I have tripled-checked the code and cant figure out why it is only showing the first few characters of the full string. Any help is appreciated. - BlueDev
   BlueDev Net [edited by - BlueDev on August 17, 2003 12:58:23 AM]
You should find that the first one is OK - unless it is in fact 4 characters long. You are not resetting the lpcName parameter (maxPath in your case).

This is an in/out variable. You pass in the maximum length the string can be, and the system returns to you the actual length of the string. So you just need to reset maxPath each time around the loop before you call RegEnumKeyEx again.

"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan

[edited by - JY on August 18, 2003 3:47:47 AM]

Share this post

Link to post
Share on other sites
Ok, thanks for the help, and also ill figure out how to reset the maxPath each time around. I once tried ''maxPath = 0'' each time but now all strings come out to be ''!'' but I think I have to do something differently but it''ll show itself, hehe.

- BlueDev

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!