Thread: RegQueryValueEx Giving error 234

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    20

    RegQueryValueEx Giving error 234

    RegQueryValueEx(key,REG_DAYCNT,NULL,&type,(LPBYTE) &dayqry,&size)
    the first time i run this statement in my program i get a 234 (ERROR_MORE_DATA ) error . I looked it up but its about not having enough buffer memory. My concern is that when i run the same statement again it works perfectly. Also about the buffer not being big enough is kinda strange because im quering a dword -which should always be the same size i think-

    If someone can help , or know about this kind of problems please answer , thx.
    Last edited by Narcose; 07-14-2006 at 05:10 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    Show us how you're declaring all the variables you're passing to the function.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    20
    Code:
    #define REG_LIB     HKEY_CURRENT_USER
    
    const char* REG_MAP     = "SOFTWARE\\Mirrosoft\\Autoshutdown";
    const char* REG_CNTDWN  = "CNTDWN";
    const char* REG_DAYCNT  = "DAYCNT";
    const char* REG_LIMIT   = "LIMIT";
    ....
    
    int getVartime(void)
    {
      HKEY key;
      DWORD result;
      int toReturn=0;
    
      if(testInitRun(DEFAULTTIME,DEFAULTTIME,curTime()));
    
      if(ERROR_SUCCESS != RegCreateKeyEx(REG_LIB,REG_MAP,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&key,&result))
      {
        printf("Problem opening registry\n");
      }
      else
      {
        DWORD limitqry;
        DWORD cntqry;
        DWORD dayqry=0;
        DWORD type;
        DWORD size;
        int test;
        
        //Is it a new day??
        if(ERROR_SUCCESS != (test = RegQueryValueEx(key,REG_DAYCNT,NULL,&type,(LPBYTE)&dayqry,&size)))
        {
         printf("Problem opening registry\n %d\n",test);
         //RegQueryValueEx(key,REG_DAYCNT,NULL,&type,(LPBYTE)&dayqry,&size);
        }
      ...
    in the last if part it goes wrong , if i uncomment the second query , the second one works then correctly
    Last edited by Narcose; 07-14-2006 at 07:01 AM.

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The size argument is an in/out argument. So you need to initialise it:
    Code:
        DWORD size = sizeof(dayqry);
        int test;
        
        //Is it a new day??
        if(ERROR_SUCCESS != (test = RegQueryValueEx(key,REG_DAYCNT,NULL,&type,(LPBYTE)&dayqry,&size)))

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    20
    that seems to be it ; thx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing a pointer to string giving segmentaion fault
    By Alexpo in forum C Programming
    Replies: 15
    Last Post: 10-10-2008, 05:11 AM
  2. giving value to structure elements
    By sarathius in forum C Programming
    Replies: 3
    Last Post: 04-21-2008, 01:24 AM
  3. Help with RegQueryValueEx
    By centimel in forum C Programming
    Replies: 6
    Last Post: 01-08-2008, 07:38 PM
  4. RegQueryValueEx problem
    By BobS0327 in forum Windows Programming
    Replies: 4
    Last Post: 10-08-2006, 08:11 PM