No Errors but wrong values on return?
-
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
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
-
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, 48Also 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));
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 !!
-
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 !!
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. SinceDWORD
s andWORD
s 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
-
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 !!
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 prefixl
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
ordwProductVersionMS
?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.
-
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 prefixl
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
ordwProductVersionMS
?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.
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
-
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 prefixl
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
ordwProductVersionMS
?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.
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
-
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
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 ... -
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 ...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.
-
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.
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.
-
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.
-
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