Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. why i could only read one charactor? [modified]

why i could only read one charactor? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    steven_wong
    wrote on last edited by
    #1

    hello, everyone: i am now in trouble with the code below: char temp[256]; LONG cbData=80; RegOpenKeyEx(...&hKey); RegQueryValue(hKey,NULL,(LPTSTR)temp,&cbData); strcat(temp,"\\abc"); with the last line above , i could only retrieve the first charactor in temp,and the result is just *\abc. I am confused....is there anyone could help me?Thanks in advance~

    modified on Monday, June 2, 2008 12:32 AM

    J R 2 Replies Last reply
    0
    • S steven_wong

      hello, everyone: i am now in trouble with the code below: char temp[256]; LONG cbData=80; RegOpenKeyEx(...&hKey); RegQueryValue(hKey,NULL,(LPTSTR)temp,&cbData); strcat(temp,"\\abc"); with the last line above , i could only retrieve the first charactor in temp,and the result is just *\abc. I am confused....is there anyone could help me?Thanks in advance~

      modified on Monday, June 2, 2008 12:32 AM

      J Offline
      J Offline
      Jijo Raj
      wrote on last edited by
      #2

      steven_wong wrote:

      strcat(tem,"\\abc");

      tem or temp? Just a typo while framing the question or some other temporary variable? Regards, Jijo.

      _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

      S 1 Reply Last reply
      0
      • J Jijo Raj

        steven_wong wrote:

        strcat(tem,"\\abc");

        tem or temp? Just a typo while framing the question or some other temporary variable? Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        S Offline
        S Offline
        steven_wong
        wrote on last edited by
        #3

        temp,i am sorry ;P

        1 Reply Last reply
        0
        • S steven_wong

          hello, everyone: i am now in trouble with the code below: char temp[256]; LONG cbData=80; RegOpenKeyEx(...&hKey); RegQueryValue(hKey,NULL,(LPTSTR)temp,&cbData); strcat(temp,"\\abc"); with the last line above , i could only retrieve the first charactor in temp,and the result is just *\abc. I am confused....is there anyone could help me?Thanks in advance~

          modified on Monday, June 2, 2008 12:32 AM

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          MSDN says: RegQueryValue is provided only for compatibility with 16-bit versions of Windows. Applications should use the RegQueryValueEx function. Besides that, what do you mean by: LONG cbData = 80? How do you know that this would be enough? RegQueryValueEx returns ERROR_SUCCESS if successful. Did you check the return value of the function?

          Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

          S 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            MSDN says: RegQueryValue is provided only for compatibility with 16-bit versions of Windows. Applications should use the RegQueryValueEx function. Besides that, what do you mean by: LONG cbData = 80? How do you know that this would be enough? RegQueryValueEx returns ERROR_SUCCESS if successful. Did you check the return value of the function?

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

            S Offline
            S Offline
            steven_wong
            wrote on last edited by
            #5

            thank u for ur replying, Rajesh ;) i c that,however, now i need to read the default value of a registry key, which means i could only use RegQueryValue. and i have checked if RegQueryValue returns ERROR_SUCCESS in my own codes.the codes i paste here is just for simple.anyway, thank u for ur reminding

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups