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. No Errors but wrong values on return?

No Errors but wrong values on return?

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiotestingbeta-testinghelpquestion
25 Posts 5 Posters 25 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.
  • G GESY

    I posted to you, but I think I put it on the wrong place, here is the post... Hi, I had make a lot of test and learn a lot thanks to your help, I also testing now how to work with those values. And I was wondering is there a way to return the HIWORD(pvi->dwFileVersionMS) and LOWORD(pvi->dwFileVersionMS) as a single long value instead of converting to a string and then back to a number, the reason I said that is because I have been testing with this code below... // wsprintf(BUFF,("%u.%u"),HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS)); // double RTVAL=atof(BUFF); // if(RTVAL==6.1) MessageBox(hwnd,"It is 6.1","atof return",MB_OK); // Tested OK RTVAL was 6.1 // return RTVA; Thanks

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #21

    Why are you converting a string to a double just to do a simple comparison? Use a string comparer (strcmp) like:

    if(strcmp(BUFF, "6.1") == 0) MessageBox(hwnd,"It is 6.1","version",MB_OK); // Tested OK RTVAL was 6.1

    Or even simpler

    if (HIWORD(pvi->dwProductVersionMS) == 6 && LOWORD(pvi->dwProductVersionMS) == 1)
    MessageBox ...

    G 1 Reply Last reply
    0
    • L Lost User

      Why are you converting a string to a double just to do a simple comparison? Use a string comparer (strcmp) like:

      if(strcmp(BUFF, "6.1") == 0) MessageBox(hwnd,"It is 6.1","version",MB_OK); // Tested OK RTVAL was 6.1

      Or even simpler

      if (HIWORD(pvi->dwProductVersionMS) == 6 && LOWORD(pvi->dwProductVersionMS) == 1)
      MessageBox ...

      G Offline
      G Offline
      GESY
      wrote on last edited by
      #22

      No my friend those are just experimenting I discover that I could do that, but the main point using the right fields of the struct and the formatting YOU teach me a lot with that. The question was is there is way to combine both Hiword & Loword and return it as a single long / decimal number, take a look to the idea below. long THEVERSION { Source code here like before return THEVERSIO; // This will be a long or double with the value of 6.1 or whatever. } That function will return 6.1 ( one single number ) is this possible? and thanks again.

      L 1 Reply Last reply
      0
      • G GESY

        No my friend those are just experimenting I discover that I could do that, but the main point using the right fields of the struct and the formatting YOU teach me a lot with that. The question was is there is way to combine both Hiword & Loword and return it as a single long / decimal number, take a look to the idea below. long THEVERSION { Source code here like before return THEVERSIO; // This will be a long or double with the value of 6.1 or whatever. } That function will return 6.1 ( one single number ) is this possible? and thanks again.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #23

        No, it would be difficult, since a LONG type would have to hold the number as 61, or even 611 if the low order value was 11. Each of the four fields are independent values which represent the Major, Minor, Revision and Build numbers of the version. It does not make sense to try and combine them into a single value.

        G 1 Reply Last reply
        0
        • L Lost User

          No, it would be difficult, since a LONG type would have to hold the number as 61, or even 611 if the low order value was 11. Each of the four fields are independent values which represent the Major, Minor, Revision and Build numbers of the version. It does not make sense to try and combine them into a single value.

          G Offline
          G Offline
          GESY
          wrote on last edited by
          #24

          I got a feeling you going to said that, I tough that maybe was a function that will put the two together, with a decimal number in between to values. Anyway....... 10000000 of thanks, I learn a lot thanks to you !!! :thumbsup:

          1 Reply Last reply
          0
          • G GESY

            I had see many examples on getting the windows version, this is not the case. Even Microsoft on on a web page show a funtion that does not work as it shows. Thank

            U Offline
            U Offline
            User 14053389
            wrote on last edited by
            #25

            I have no idea about this. But I will try it on my

            wow computer

            .

            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