can you help me figure out why im getting this error.. here is my code
sorry about the length.. any help would be greatly appreciatedCode:#include <string> #include <stdio.h> #include <windows.h> #include <tchar.h> #include <fstream> #include <iostream> using namespace std; ifstream fin; ofstream fout; #define MAX_KEY_LENGTH 255 #define MAX_VALUE_NAME 16383 void main() { fout.open("value.txt"); string name = getenv("computername"); fout << "workstation name: " << name << endl; // DO NOT TOUCH... TOOK FROM MICROSOFTS WEB PAGE!! except where I replaced i with K (for keys // and added V (for values) this way I get enumkeys and enumvalues to loop when I want. ////////////////////////////////////////////////////////////////////////////////////// TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name DWORD cbName; // size of name string TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name DWORD cchClassName = MAX_PATH; // size of class string DWORD cSubKeys=0; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time TCHAR achData[MAX_VALUE_NAME]; DWORD cchData = MAX_VALUE_NAME; DWORD K, V, retCode; TCHAR achValue[MAX_VALUE_NAME]; DWORD cchValue = MAX_VALUE_NAME; K=0; ////////////////////////////////////////////////////////////////////////////////////// // MY STUFF AND MODFIFIED FUNCTIONS FROM MICROSOFT START HERE int C = 0; int A = 0; //tracks the current char value being looked at in Skey int B = 0; //tracks the current char value for Add int Fix = 0; int Fix2 = 0; // sets the limit of loops to the ammount of keys in the innitial Skey value // was having an issue where it would stop after opening the Sub sub key.. because // there where no subkeys in that subkey TCHAR add[MAX_KEY_LENGTH] = ""; TCHAR Skey[MAX_KEY_LENGTH] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"; do { // Changes Skey back to its original "Software\\....\\Uninstall\\" do { A = 52; if(Skey[A] != NULL && A < 255) { Skey[A] = NULL; A++; } else A = 255; } while(A < 255); A = 0; B = 0; // Adds add to the end of Skey A = 52; if(Fix == 0) { Fix =1; do { if(add[B] == NULL && Skey[A] == NULL) { A= 255; } if(add[B] == NULL) { Skey[A] = NULL; A++; B++; } if(Skey[A] == NULL || Skey != NULL) { Skey[A] = add[B]; A++; B++; } } while(A < 255); } A = 0; B = 0; HKEY hTestKey = HKEY_LOCAL_MACHINE; // I CHANGED THE SECOND INPUT FROM BEING A STATIC "\\SOFTWARE\\...ETC to Skey // which can be CHANGED.. YAYAYAYAY.. took long enough. if (RegOpenKeyEx(hTestKey, Skey, 0, KEY_READ, &hTestKey) == ERROR_SUCCESS) // THIS IS MICROSOFTS.. NOT GONNA TOUCH IT UNTILL IT ADDS A VALUE TO ACHKEY. // at this point I need to make ADD = ACHKEY so that ADD will add onto Skey // to search deeper in the regestry // Get the class name and the value count. retCode = RegQueryInfoKey( hTestKey, // key handle achClass, // buffer for class name &cchClassName, // size of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time // Enumerate the subkeys, until RegEnumKeyEx fails. if (Fix2 == 0) { Fix2 = cSubKeys; } if (cSubKeys) { if(C == 0) { fout << "Number of subkeys: " << cSubKeys << endl; C = 1; } cbName = MAX_KEY_LENGTH; retCode = RegEnumKeyEx(hTestKey, K, achKey, &cbName, NULL, NULL, NULL, &ftLastWriteTime); if (retCode == ERROR_SUCCESS) { fout << "<" << K+1 << "> " << achKey << endl; } Fix--; K ++; } // nulls add and adds achKey to add A = 0; B = 0; do { add[A] = NULL; A++; } while(A <255 ); A = 0; do { if(achKey[B] == NULL) { A = 255; } if(achKey[B] != NULL) { add[A] = achKey[B]; A++; B++; } } while(A < 255); A = 0; B = 0; // Enumerate the key values. if (cValues) { fout << " Number of values: " << cValues << endl; for (V=0, retCode=ERROR_SUCCESS; V<cValues; V++) { cchValue = MAX_VALUE_NAME; achValue[0] = '\0'; retCode = RegEnumValue(hTestKey, V, achValue, &cchValue, NULL, NULL, NULL, NULL); if (retCode == ERROR_SUCCESS ) { fout << " (" << V+1 << ")" << achValue << endl; } RegGetValue(hTestKey, Skey, achValue, NULL, NULL, achData, &cchData); cout << achData << endl; } } } while(K<Fix2 +1); fout.close(); }



LinkBack URL
About LinkBacks


