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 Offline
    G Offline
    GESY
    wrote on last edited by
    #1

    I trying to get the Version of the ComCtl32.dll library, according to what I had read the version number for the ony on System 32 is 5.82 for legacy. This is the code I have created, and cant get any close to that, you will see extra lines of code for testing purposes, I maybe not even doing right the creation of the string for the dialog box, check it out please teach me /give some tips why I get wrong values. The Code ( Noticed the return 1 or 0 in case of no or errors ) and 1000 of thanks in advance. char NFILE[255]; DWORD dwSize, dwHandle = 0; VS_FIXEDFILEINFO * pvi; // Set the Path and file name strcpy(NFILE,"C:\\Windows\\System32\\ComCtl32.dll"); MessageBox(hWndMain,NFILE,"",MB_OK); // Testing // Check if we can reach the library. if(LoadLibrary(NFILE)==NULL) return 1; // If NULL there is an error // Check if Version info can retrieve and returns the size, in bytes, of that information. dwSize = GetFileVersionInfoSize( NFILE, NULL ); // Link the Version.lib Library first if(dwSize==0) MessageBox(hwnd,"Error","",MB_OK); // 0 means an Error // Get the file Information char *FDBUF = new char[dwSize]; if ( !GetFileVersionInfo( NFILE, dwHandle, dwSize, &FDBUF[ 0 ] ) ) { delete FDBUF; return 1; } // If not true, delete the buffer and return // Get the information into the VS_FIXEDFILEINFO Structure dwSize = sizeof(VS_FIXEDFILEINFO); if ( !VerQueryValue( & FDBUF[ 0 ], "\\", (LPVOID*)&pvi, (unsigned int*)&dwSize ) ) { delete FDBUF; return 1; } // Error processing the information structure. // Original values according to windows File Version is 5.82 on System32 for legacy // The 6.0 version lives in %SystemRoot%\winsxs. wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS))); MessageBox(hwnd,BUFF,"The Value",MB_OK); // Display the value delete FDBUF; return 0;

    V L D 4 Replies Last reply
    0
    • G GESY

      I trying to get the Version of the ComCtl32.dll library, according to what I had read the version number for the ony on System 32 is 5.82 for legacy. This is the code I have created, and cant get any close to that, you will see extra lines of code for testing purposes, I maybe not even doing right the creation of the string for the dialog box, check it out please teach me /give some tips why I get wrong values. The Code ( Noticed the return 1 or 0 in case of no or errors ) and 1000 of thanks in advance. char NFILE[255]; DWORD dwSize, dwHandle = 0; VS_FIXEDFILEINFO * pvi; // Set the Path and file name strcpy(NFILE,"C:\\Windows\\System32\\ComCtl32.dll"); MessageBox(hWndMain,NFILE,"",MB_OK); // Testing // Check if we can reach the library. if(LoadLibrary(NFILE)==NULL) return 1; // If NULL there is an error // Check if Version info can retrieve and returns the size, in bytes, of that information. dwSize = GetFileVersionInfoSize( NFILE, NULL ); // Link the Version.lib Library first if(dwSize==0) MessageBox(hwnd,"Error","",MB_OK); // 0 means an Error // Get the file Information char *FDBUF = new char[dwSize]; if ( !GetFileVersionInfo( NFILE, dwHandle, dwSize, &FDBUF[ 0 ] ) ) { delete FDBUF; return 1; } // If not true, delete the buffer and return // Get the information into the VS_FIXEDFILEINFO Structure dwSize = sizeof(VS_FIXEDFILEINFO); if ( !VerQueryValue( & FDBUF[ 0 ], "\\", (LPVOID*)&pvi, (unsigned int*)&dwSize ) ) { delete FDBUF; return 1; } // Error processing the information structure. // Original values according to windows File Version is 5.82 on System32 for legacy // The 6.0 version lives in %SystemRoot%\winsxs. wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS))); MessageBox(hwnd,BUFF,"The Value",MB_OK); // Display the value delete FDBUF; return 0;

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      You could get some ideas from this discussion: [c++ - Why does GetFileVersionInfo on kernel32.dll in windows 10 returns version 6.2? - Stack Overflow](https://stackoverflow.com/questions/38068477/why-does-getfileversioninfo-on-kernel32-dll-in-windows-10-returns-version-6-2) and this Chris Maunder's article: [Determining the version number of the Windows system libraries](https://www.codeproject.com/Articles/322/Determining-the-version-number-of-the-Windows-syst)

      G 1 Reply Last reply
      0
      • G GESY

        I trying to get the Version of the ComCtl32.dll library, according to what I had read the version number for the ony on System 32 is 5.82 for legacy. This is the code I have created, and cant get any close to that, you will see extra lines of code for testing purposes, I maybe not even doing right the creation of the string for the dialog box, check it out please teach me /give some tips why I get wrong values. The Code ( Noticed the return 1 or 0 in case of no or errors ) and 1000 of thanks in advance. char NFILE[255]; DWORD dwSize, dwHandle = 0; VS_FIXEDFILEINFO * pvi; // Set the Path and file name strcpy(NFILE,"C:\\Windows\\System32\\ComCtl32.dll"); MessageBox(hWndMain,NFILE,"",MB_OK); // Testing // Check if we can reach the library. if(LoadLibrary(NFILE)==NULL) return 1; // If NULL there is an error // Check if Version info can retrieve and returns the size, in bytes, of that information. dwSize = GetFileVersionInfoSize( NFILE, NULL ); // Link the Version.lib Library first if(dwSize==0) MessageBox(hwnd,"Error","",MB_OK); // 0 means an Error // Get the file Information char *FDBUF = new char[dwSize]; if ( !GetFileVersionInfo( NFILE, dwHandle, dwSize, &FDBUF[ 0 ] ) ) { delete FDBUF; return 1; } // If not true, delete the buffer and return // Get the information into the VS_FIXEDFILEINFO Structure dwSize = sizeof(VS_FIXEDFILEINFO); if ( !VerQueryValue( & FDBUF[ 0 ], "\\", (LPVOID*)&pvi, (unsigned int*)&dwSize ) ) { delete FDBUF; return 1; } // Error processing the information structure. // Original values according to windows File Version is 5.82 on System32 for legacy // The 6.0 version lives in %SystemRoot%\winsxs. wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS))); MessageBox(hwnd,BUFF,"The Value",MB_OK); // Display the value delete FDBUF; return 0;

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

        GESY wrote:

        according to what I had read

        Where did you read this information?

        GESY wrote:

        This is the code I have created, and cant get any close to that

        So what value do you actually get? And have you checked the details in the property page of the DLL? I just ran your code on my Windows 10 system and get FileVersion of 5.82, and ProductVersion of 10.0, which I think is probably correct.

        G 1 Reply Last reply
        0
        • L Lost User

          GESY wrote:

          according to what I had read

          Where did you read this information?

          GESY wrote:

          This is the code I have created, and cant get any close to that

          So what value do you actually get? And have you checked the details in the property page of the DLL? I just ran your code on my Windows 10 system and get FileVersion of 5.82, and ProductVersion of 10.0, which I think is probably correct.

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

          Most likely is the conversion or formatting string, I dont undertand much the wsprintf funtion, I get big weir numbers, nothing like what you said. If the code is correct, then have to be displaying on a message Box. Can you help with this? Thanks :) :) :)

          D L 2 Replies Last reply
          0
          • V Victor Nijegorodov

            You could get some ideas from this discussion: [c++ - Why does GetFileVersionInfo on kernel32.dll in windows 10 returns version 6.2? - Stack Overflow](https://stackoverflow.com/questions/38068477/why-does-getfileversioninfo-on-kernel32-dll-in-windows-10-returns-version-6-2) and this Chris Maunder's article: [Determining the version number of the Windows system libraries](https://www.codeproject.com/Articles/322/Determining-the-version-number-of-the-Windows-syst)

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

            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

            V U 2 Replies 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

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #6

              GESY wrote:

              I had see many examples on getting the windows version, this is not the case.

              But you try at least some of them?

              G 1 Reply Last reply
              0
              • G GESY

                Most likely is the conversion or formatting string, I dont undertand much the wsprintf funtion, I get big weir numbers, nothing like what you said. If the code is correct, then have to be displaying on a message Box. Can you help with this? Thanks :) :) :)

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                GESY wrote:

                ...I get big weir numbers...

                Such as?

                GESY wrote:

                If the code is correct, then have to be displaying on a message Box.

                What exactly does this mean?

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                1 Reply Last reply
                0
                • G GESY

                  I trying to get the Version of the ComCtl32.dll library, according to what I had read the version number for the ony on System 32 is 5.82 for legacy. This is the code I have created, and cant get any close to that, you will see extra lines of code for testing purposes, I maybe not even doing right the creation of the string for the dialog box, check it out please teach me /give some tips why I get wrong values. The Code ( Noticed the return 1 or 0 in case of no or errors ) and 1000 of thanks in advance. char NFILE[255]; DWORD dwSize, dwHandle = 0; VS_FIXEDFILEINFO * pvi; // Set the Path and file name strcpy(NFILE,"C:\\Windows\\System32\\ComCtl32.dll"); MessageBox(hWndMain,NFILE,"",MB_OK); // Testing // Check if we can reach the library. if(LoadLibrary(NFILE)==NULL) return 1; // If NULL there is an error // Check if Version info can retrieve and returns the size, in bytes, of that information. dwSize = GetFileVersionInfoSize( NFILE, NULL ); // Link the Version.lib Library first if(dwSize==0) MessageBox(hwnd,"Error","",MB_OK); // 0 means an Error // Get the file Information char *FDBUF = new char[dwSize]; if ( !GetFileVersionInfo( NFILE, dwHandle, dwSize, &FDBUF[ 0 ] ) ) { delete FDBUF; return 1; } // If not true, delete the buffer and return // Get the information into the VS_FIXEDFILEINFO Structure dwSize = sizeof(VS_FIXEDFILEINFO); if ( !VerQueryValue( & FDBUF[ 0 ], "\\", (LPVOID*)&pvi, (unsigned int*)&dwSize ) ) { delete FDBUF; return 1; } // Error processing the information structure. // Original values according to windows File Version is 5.82 on System32 for legacy // The 6.0 version lives in %SystemRoot%\winsxs. wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS))); MessageBox(hwnd,BUFF,"The Value",MB_OK); // Display the value delete FDBUF; return 0;

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  GESY wrote:

                  char *FDBUF = new char[dwSize];

                  If dwSize is 0, this allocation is pointless. In other words, don't continue if GetFileVersionInfoSize() did not return anything useful.

                  GESY wrote:

                  wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS)));

                  To match the Details tab of the Properties dialog, I'd think you'd want something similar to:

                  wsprintf(BUFF, _T("File version is %u.%u.%u.%u"), HIWORD(pvi->dwFileVersionMS), LOWORD(pvi->dwFileVersionMS), HIWORD(pvi->dwFileVersionLS), LOWORD(pvi->dwFileVersionLS));
                  …
                  wsprintf(BUFF, _T("Product version is %u.%u.%u.%u"), HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS), HIWORD(pvi->dwProductVersionLS), LOWORD(pvi->dwProductVersionLS));

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                  G 2 Replies Last reply
                  0
                  • G GESY

                    Most likely is the conversion or formatting string, I dont undertand much the wsprintf funtion, I get big weir numbers, nothing like what you said. If the code is correct, then have to be displaying on a message Box. Can you help with this? Thanks :) :) :)

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

                    GESY wrote:

                    I get big weir numbers

                    Yes, but you never tell us what the actual values are. Please don't think we can guess what results you see on your screen.

                    1 Reply Last reply
                    0
                    • G GESY

                      I trying to get the Version of the ComCtl32.dll library, according to what I had read the version number for the ony on System 32 is 5.82 for legacy. This is the code I have created, and cant get any close to that, you will see extra lines of code for testing purposes, I maybe not even doing right the creation of the string for the dialog box, check it out please teach me /give some tips why I get wrong values. The Code ( Noticed the return 1 or 0 in case of no or errors ) and 1000 of thanks in advance. char NFILE[255]; DWORD dwSize, dwHandle = 0; VS_FIXEDFILEINFO * pvi; // Set the Path and file name strcpy(NFILE,"C:\\Windows\\System32\\ComCtl32.dll"); MessageBox(hWndMain,NFILE,"",MB_OK); // Testing // Check if we can reach the library. if(LoadLibrary(NFILE)==NULL) return 1; // If NULL there is an error // Check if Version info can retrieve and returns the size, in bytes, of that information. dwSize = GetFileVersionInfoSize( NFILE, NULL ); // Link the Version.lib Library first if(dwSize==0) MessageBox(hwnd,"Error","",MB_OK); // 0 means an Error // Get the file Information char *FDBUF = new char[dwSize]; if ( !GetFileVersionInfo( NFILE, dwHandle, dwSize, &FDBUF[ 0 ] ) ) { delete FDBUF; return 1; } // If not true, delete the buffer and return // Get the information into the VS_FIXEDFILEINFO Structure dwSize = sizeof(VS_FIXEDFILEINFO); if ( !VerQueryValue( & FDBUF[ 0 ], "\\", (LPVOID*)&pvi, (unsigned int*)&dwSize ) ) { delete FDBUF; return 1; } // Error processing the information structure. // Original values according to windows File Version is 5.82 on System32 for legacy // The 6.0 version lives in %SystemRoot%\winsxs. wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS))); MessageBox(hwnd,BUFF,"The Value",MB_OK); // Display the value delete FDBUF; return 0;

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

                      You are using the wrong fields to get the values. The versions are stored in the following way:

                      dwProductVersionMS, contains the major fields, HIWORD, LOWORD e.g. 10, 0
                      dwProductVersionLS, contains the minor fields as above, e.g. 17134, 48

                      Also you are only printing one number, but passing two values in your wsprintf statement. So it should be:

                      wsprintf(BUFF, "Version is %d.%d",HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS));

                      G 2 Replies Last reply
                      0
                      • V Victor Nijegorodov

                        GESY wrote:

                        I had see many examples on getting the windows version, this is not the case.

                        But you try at least some of them?

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

                        The examples that I had seen use a function that is just for the operating system. I looking to read the version of any file. 10000 of thanks

                        1 Reply Last reply
                        0
                        • L Lost User

                          You are using the wrong fields to get the values. The versions are stored in the following way:

                          dwProductVersionMS, contains the major fields, HIWORD, LOWORD e.g. 10, 0
                          dwProductVersionLS, contains the minor fields as above, e.g. 17134, 48

                          Also you are only printing one number, but passing two values in your wsprintf statement. So it should be:

                          wsprintf(BUFF, "Version is %d.%d",HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS));

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

                          Now that's what I call a good explanation!!! 1000 of thanks to you sr. I will try that a will let you know....... 1000 of thanks again.!!!

                          1 Reply Last reply
                          0
                          • D David Crow

                            GESY wrote:

                            char *FDBUF = new char[dwSize];

                            If dwSize is 0, this allocation is pointless. In other words, don't continue if GetFileVersionInfoSize() did not return anything useful.

                            GESY wrote:

                            wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS)));

                            To match the Details tab of the Properties dialog, I'd think you'd want something similar to:

                            wsprintf(BUFF, _T("File version is %u.%u.%u.%u"), HIWORD(pvi->dwFileVersionMS), LOWORD(pvi->dwFileVersionMS), HIWORD(pvi->dwFileVersionLS), LOWORD(pvi->dwFileVersionLS));
                            …
                            wsprintf(BUFF, _T("Product version is %u.%u.%u.%u"), HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS), HIWORD(pvi->dwProductVersionLS), LOWORD(pvi->dwProductVersionLS));

                            "One man's wage rise is another man's price increase." - Harold Wilson

                            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

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

                            Auch!! Now I getting good help, someone here responded like you and to you too 10000 of thanks, for a good help and explanation !! I will try that later when I have a chance and keep you posted.

                            1 Reply Last reply
                            0
                            • D David Crow

                              GESY wrote:

                              char *FDBUF = new char[dwSize];

                              If dwSize is 0, this allocation is pointless. In other words, don't continue if GetFileVersionInfoSize() did not return anything useful.

                              GESY wrote:

                              wsprintf(BUFF, "Version is %d",LOBYTE(LOWORD(pvi->dwProductVersionLS)),HIBYTE(LOWORD(pvi->dwProductVersionMS)));

                              To match the Details tab of the Properties dialog, I'd think you'd want something similar to:

                              wsprintf(BUFF, _T("File version is %u.%u.%u.%u"), HIWORD(pvi->dwFileVersionMS), LOWORD(pvi->dwFileVersionMS), HIWORD(pvi->dwFileVersionLS), LOWORD(pvi->dwFileVersionLS));
                              …
                              wsprintf(BUFF, _T("Product version is %u.%u.%u.%u"), HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS), HIWORD(pvi->dwProductVersionLS), LOWORD(pvi->dwProductVersionLS));

                              "One man's wage rise is another man's price increase." - Harold Wilson

                              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

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

                              I tested your lines of code, and was great, finally I can see what I was looking for !!! I also thanks to the code you give me, I understand better that " wsprintf " function. Now front the programmers point of view, if you testing for a particular dll that you need to be some specific version, which one would you use? Using dwFileVersionMS, The result was 5.82 Using dwProductVersionMS The result was 6.1 And 1000 of thanks again!!! :-D

                              D 1 Reply Last reply
                              0
                              • G GESY

                                I tested your lines of code, and was great, finally I can see what I was looking for !!! I also thanks to the code you give me, I understand better that " wsprintf " function. Now front the programmers point of view, if you testing for a particular dll that you need to be some specific version, which one would you use? Using dwFileVersionMS, The result was 5.82 Using dwProductVersionMS The result was 6.1 And 1000 of thanks again!!! :-D

                                D Offline
                                D Offline
                                David Crow
                                wrote on last edited by
                                #15

                                GESY wrote:

                                ...which one would you use?

                                That would depend on if I wanted to know the product's version or the file's version. They're two different things.

                                "One man's wage rise is another man's price increase." - Harold Wilson

                                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                                1 Reply Last reply
                                0
                                • L Lost User

                                  You are using the wrong fields to get the values. The versions are stored in the following way:

                                  dwProductVersionMS, contains the major fields, HIWORD, LOWORD e.g. 10, 0
                                  dwProductVersionLS, contains the minor fields as above, e.g. 17134, 48

                                  Also you are only printing one number, but passing two values in your wsprintf statement. So it should be:

                                  wsprintf(BUFF, "Version is %d.%d",HIWORD(pvi->dwProductVersionMS), LOWORD(pvi->dwProductVersionMS));

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

                                  I tested your lines of code, and now I can see what I was looking for! Well done, plus you even give an explanation of the fields and what they do. ( You told me: dwProductVersionMS, contains the major fields, HIWORD, LOWORD e.g. 10, 0 dwProductVersionLS, contains the minor fields as above, e.g. 17134, 48 ) Excellent! I must ask you, you using %d but I had seen %u I believe one is for a integer and the other for a long ? Which one is correct or does that matter based on the function we testing? And finally in programming which value would you do a test for? Using dwFileVersionMS, The result was 5.82 Using dwProductVersionMS The result was 6.1 And before I go...... 1000 of thanks !!

                                  D L 2 Replies Last reply
                                  0
                                  • G GESY

                                    I tested your lines of code, and now I can see what I was looking for! Well done, plus you even give an explanation of the fields and what they do. ( You told me: dwProductVersionMS, contains the major fields, HIWORD, LOWORD e.g. 10, 0 dwProductVersionLS, contains the minor fields as above, e.g. 17134, 48 ) Excellent! I must ask you, you using %d but I had seen %u I believe one is for a integer and the other for a long ? Which one is correct or does that matter based on the function we testing? And finally in programming which value would you do a test for? Using dwFileVersionMS, The result was 5.82 Using dwProductVersionMS The result was 6.1 And before I go...... 1000 of thanks !!

                                    D Offline
                                    D Offline
                                    David Crow
                                    wrote on last edited by
                                    #17

                                    GESY wrote:

                                    I must ask you, you using %d but I had seen %u I believe one is for a integer and the other for a long ?

                                    %d is for a signed int and %u is for an unsigned int. Since DWORDs and WORDs are both unsigned, %u is preferred.

                                    "One man's wage rise is another man's price increase." - Harold Wilson

                                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                                    "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                                    1 Reply Last reply
                                    0
                                    • G GESY

                                      I tested your lines of code, and now I can see what I was looking for! Well done, plus you even give an explanation of the fields and what they do. ( You told me: dwProductVersionMS, contains the major fields, HIWORD, LOWORD e.g. 10, 0 dwProductVersionLS, contains the minor fields as above, e.g. 17134, 48 ) Excellent! I must ask you, you using %d but I had seen %u I believe one is for a integer and the other for a long ? Which one is correct or does that matter based on the function we testing? And finally in programming which value would you do a test for? Using dwFileVersionMS, The result was 5.82 Using dwProductVersionMS The result was 6.1 And before I go...... 1000 of thanks !!

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

                                      GESY wrote:

                                      using %d but I had seen %u

                                      That is for signed (%d) or unsigned (%u) integers. For a long value you need to add the prefix l thus:

                                      long longValue = 1000000;
                                      printf("long value: %ld\n", longValue);

                                      These format characters are explained in the MSDN documentation at Format Specification Syntax: printf and wprintf Functions[^].

                                      Quote:

                                      dwFileVersionMS or dwProductVersionMS ?

                                      Well it depends what you are testing for. The documentation for the specific product or library should tell you which one they are referring to, as they are usually different.

                                      GESY wrote:

                                      1000 of thanks

                                      Happy to help, and I learned a few useful things in the process; so we both benefit.

                                      G 2 Replies Last reply
                                      0
                                      • L Lost User

                                        GESY wrote:

                                        using %d but I had seen %u

                                        That is for signed (%d) or unsigned (%u) integers. For a long value you need to add the prefix l thus:

                                        long longValue = 1000000;
                                        printf("long value: %ld\n", longValue);

                                        These format characters are explained in the MSDN documentation at Format Specification Syntax: printf and wprintf Functions[^].

                                        Quote:

                                        dwFileVersionMS or dwProductVersionMS ?

                                        Well it depends what you are testing for. The documentation for the specific product or library should tell you which one they are referring to, as they are usually different.

                                        GESY wrote:

                                        1000 of thanks

                                        Happy to help, and I learned a few useful things in the process; so we both benefit.

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

                                        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

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          GESY wrote:

                                          using %d but I had seen %u

                                          That is for signed (%d) or unsigned (%u) integers. For a long value you need to add the prefix l thus:

                                          long longValue = 1000000;
                                          printf("long value: %ld\n", longValue);

                                          These format characters are explained in the MSDN documentation at Format Specification Syntax: printf and wprintf Functions[^].

                                          Quote:

                                          dwFileVersionMS or dwProductVersionMS ?

                                          Well it depends what you are testing for. The documentation for the specific product or library should tell you which one they are referring to, as they are usually different.

                                          GESY wrote:

                                          1000 of thanks

                                          Happy to help, and I learned a few useful things in the process; so we both benefit.

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

                                          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 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