Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Ok, fairly new to C++ coding... I can create a window and do basic functions such as dialog boxes, text boxes, etc...

I'm trying to access the registry and put the keys in a textbox just for starters. I've tried everything from the MS site and other tutorials with no luck. The problem is that Dev just gives me errors when I try to run the given code...

Here's my recent try to just get basic registry size info...

#include <iostream> //Basic (cin, cout)
#include <string> //Basic (string.length(), etc..)
#include <clocale>
#include <windows.h>
#include <stdio.h>
using namespace std;

void clear();
int i1, i2;
DWORD dwQuotaAllowed, dwQuotaUsed;
GetSystemRegistryQuota(dwQuotaAllowed, i1);
GetSystemRegistryQuota(dwQuotaUsed, i2);

int main(int argc, char * argv[])
{
  
    /* printf( "Quota allowed: %uK, Quota used: %uK\n",
            dwQuotaAllowed/1024, dwQuotaUsed / 1024 ); */
  
  cout << "Locale Drive: " << setlocale(LC_ALL,NULL) << endl << endl;
  
  cout << "Total Allowable Registry Size: " << i1 << endl;
  cout << "Current Registry Size: " << i2 << endl;
  
  string sXit;
  int iXit = 1;
  char z;
  bool x = false;
  sXit.clear();
  do
  {
    sXit.clear();
    cout << "Exit? (y/n): ";
    getline(cin, sXit);
    if ((sXit == "") || (sXit == " "))
    {
      iXit = 1; //Default Exit = "y" if blank space or Enter key
      x = false;
      break;
    }
    z = sXit.at(0);
    switch (z) //User can answer yes or no ("y" or "n")
    {
      case 'y':
        iXit = 1;
        x = false;
        break;
      case 'n':
        iXit = 0;
        x = false;
        break;
      default:
        x = true;
    }
  } while(x);
  return 0;
}


All I get is constructor errors with GetSystemRegistryQuota, any ideas?

Reformatted, -EG-
Posted
Updated 9-Jul-11 20:46pm
v2
Comments
Sergey Alexandrovich Kryukov 10-Jul-11 0:31am    
Compile-time error, run-time (exception)? Where is exception dump, in what lines?
--SA
ThatsAlok 11-Jul-11 5:08am    
what about keeping setting in INI file!

You need to move the lines of code above your definition of main inside the main block of your program. As it stands the two GetSystemRegistryQuota() function calls can never be executed.
 
Share this answer
 
Comments
Espen Harlinn 10-Jul-11 14:49pm    
Right, my 5
DWORD dwQuotaAllowed, dwQuotaUsed;
GetSystemRegistryQuota(&dwQuotaAllowed,&dwQuotaUsed);

pdwQuotaAllowed and pdwQuotaUsed need to be a pointer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900