QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: krovit on October 30, 2020, 05:16:27 am
-
I am in trouble to determine the version of windows in use.
ENVIRON$ behaves differently depending on the version of windows and use GetVersion() is Microsoft depreciated...
batch files?
Can you give me some info?
Thanks!
-
Sounds like a job for @SpriggsySpriggs!
-
Shell out to: systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
All you'll need to do is pipe the info there to clipboard, or to a file, and then read it in. (change quotes to CHR$(34) characters for the SHELL statement to avoid issues.)
Results look like this (for Win 10):
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" <-- the command
OS Name: Microsoft Windows 10 Pro <-- it's output
OS Version: 10.0.18363 N/A Build 18363 <-- on two lines... other OS versions may have more lines of information for you.
You can also just stick to the simple old VER command...
SHELL "ver>temp.txt"
OPEN "temp.txt" FOR INPUT AS #1
LINE INPUT #1, blank$ 'output is a blank line
LINE INPUT #1, ver$ 'and then the version, for some odd reason
PRINT ver$
CLOSE
KILL "temp.txt"
-
Thank you SMcNeill
I actually hoped that there would be a system to get that information without using the dear batch files, that is, without writing anything, but that's fine too. your example is complete and comprehensive.
-
I actually hoped that there would be a system to get that information without using the dear batch files, that is, without writing anything, but that's fine too
@krovit
Here is some code that doesn't require writing to a file. This is generally faster than most regular SHELLs as well. Download the attached "pipecom.h" file and put it with your code.
ver
= MID$(pipecom
("ver"), 2)
-
Important reminder: once compiled, the .h file doesn't have to be shipped with your exe, if that's a concern.
-
Hey! Thank you! now I can choose the method between the BAT file and your routine
I only have one question... I'm almost ashamed...
The *.h file seems to me to be a script in C or Java or similar languages. I saw that he goes to look for it in the same folder as the . Bas.
You tell me to import it into my code, but actually don't like that.
The fact is that no experience with the .h and QB64 files: I need a little teaching to figure out how to do in these cases...
-
Hi Krovit
in my little experience the .h files is like a DLL but GCC++ accepts it as sourceCcode at the place of a compiled file DLL.
All you need at compiling time is that the .h file must be in the QB64.exe folder and a declaration of it into the code like an external library as it does the code of Spriggsy.
At runtime you needn't the .h file, so you can think it more like a .BM file than a DLL because it has been included into the .EXE got by compilation.
PS: have you joined to Discord for QB64?
I have tried it and I find it cool!
-
Grazie TempoDiBasic
Thank you now it's very clear the help that these little routines can give to qb64.
"Discord"...? I don't know what it is!
-
"Discord"...? I don't know what it is!
QB64 chat room on Internet, see our Home Page Announcements (at bottom) 2nd Board or just link https://discord.com/invite/2t9HTYK
-
@krovit I have some new code posted here that makes the Windows version operate better. No more console window popping up.
https://www.qb64.org/forum/index.php?topic=3168.msg124345#msg124345 (https://www.qb64.org/forum/index.php?topic=3168.msg124345#msg124345)
-
Have you checked Wiki:
https://www.qb64.org/wiki/ENVIRON$
-
Have you checked Wiki:
https://www.qb64.org/wiki/ENVIRON$
He says so in the first post.
-
Man if it's not in here?
i = i + 1
setting$
= ENVIRON$(i
) ' get a setting from the list
-
Quick question, what do you need the windows version for?
-
Quick question, what do you need the windows version for?
Application behavior sometimes changes when run on windows7 or windows10.
The OS are similar but certainly not the same and every now and then you find some surprises so it is useful to predict these critical issues.
-
Man if it's not in here?
i = i + 1
setting$
= ENVIRON$(i
) ' get a setting from the list
The behavior of ENVIRON$() is different in the two systems (win10 and win7) and the result seems unreliable.
At least that's what I've checked several times on multiple machines.
QB64 probably lacks a function that simply returns (in any OS) the OS, version and even the user's name and his folder.
-
@krovit I have some new code posted here that makes the Windows version operate better. No more console window popping up.
https://www.qb64.org/forum/index.php?topic=3168.msg124345#msg124345 (https://www.qb64.org/forum/index.php?topic=3168.msg124345#msg124345)
Thank you! I consider it immediately for my applications...
-
Well this works for 10, how 'bout 7?
@krovit Same as Steve, no batch file is involved. So wth? are you just being difficult? ;-))
PS I never knew my widows version was so many characters long! ;-)
-
@bplus He also mentioned he was hoping to not have to write to a file at all.
-
Well this works for 10, how 'bout 7?
@krovit Same as Steve, no batch file is involved. So wth? are you just being difficult? ;-))
PS I never knew my widows version was so many characters long! ;-)
I'm afraid I don't understand (OT: ah! foreign languages... i'm not able to talk it... I only speak Italian, and I would hope well... it is a beautiful language, with 250 thousand words! and we use 2000 and no; inside is especially Latin and Ancient Greek, and then German, Spanish, French... lastly also English (imported as it is, but then it's not really "Italian language") and one thing we can say in a thousand ways and a thousand nuances).
The code for the batch file is fine just and it works in the two OS but forces to access the disk and if you can avoid it seems better.
-
SHELL "ver | clip" ' << I AM NOT A FREAKIN BAT FILE! ;-))
-
SHELL "ver | clip" ' << I AM NOT A FREAKIN BAT FILE! ;-))
Thank you BPlus this latest version is very, very nice and works (I have to test it on win7 to catch the differences with win10).
The previous truths, however, made use of a file (SHELL "ver > ver.txt" / OPEN "ver.txt" FOR BINARY AS #1 etc..)
Anyway... i can't understand the trick, which is how it can work...
-
https://jrsoftware.org/ishelp/index.php?topic=winvernotes (https://jrsoftware.org/ishelp/index.php?topic=winvernotes)
6.0.6000 Windows Vista
6.0.6001 Windows Vista with Service Pack 1 'or Windows Server 2008
6.1.7600 Windows 7 'or Windows Server 2008 R2
6.1.7601 Windows 7 with Service Pack 1 'or Windows Server 2008 R2 with Service Pack 1
6.2.9200 Windows 8 'or Windows Server 2012
6.3.9200 Windows 8.1 'or Windows Server 2012 R2
6.3.9600 Windows 8.1 with Update 1
10.0.10240 Windows 10 Version 1507
10.0.10586 Windows 10 Version 1511 (November Update)
10.0.14393 Windows 10 Version 1607 (Anniversary Update) 'or Windows Server 2016
10.0.15063 Windows 10 Version 1703 (Creators Update)
10.0.16299 Windows 10 Version 1709 (Fall Creators Update)
10.0.17134 Windows 10 Version 1803 (April 2018 Update)
10.0.17763 Windows 10 Version 1809 (October 2018 Update) 'or Windows Server 2019
10.0.18362 Windows 10 Version 1903 (May 2019 Update)
10.0.18363 Windows 10 Version 1909 (November 2019 Update)
10.0.19041 Windows 10 Version 2004 (May 2020 Update)
Note that there is normally no need to specify the build numbers (i.e., you may simply use "6.2" for Windows 8)
-
Thank you BPlus this latest version is very, very nice and works (I have to test it on win7 to catch the differences with win10).
The previous truths, however, made use of a file (SHELL "ver > ver.txt" / OPEN "ver.txt" FOR BINARY AS #1 etc..)
Anyway... i can't understand the trick, which is how it can work...
@krovit Just remember that by piping to clip it slows down the command sometimes to being 1/3 the speed of a regular SHELL or pipecom.
-
@krovit Just remember that by piping to clip it slows down the command sometimes to being 1/3 the speed of a regular SHELL or pipecom.
Ahhgh!!!
We say (in Italy, in your areas i don't know...): "give me a hot and a cold one", or even "a crush and a raw one"... to indicate that every time there is something that contradicts the previous time...
-
Ahhgh!!!
We say (in Italy, in your areas i don't know...): "give me a hot and a cold one", or even "a crush and a raw one"... to indicate that every time there is something that contradicts the previous time...
Instead of sighing I would demand proof ;-)) specially if clipboard is cleared before piping. :O
Besides what's 1/3 or .001, you only do it once, sip some coffee ;-))
-
Instead of sighing I would demand proof ;-)) specially if clipboard is cleared before piping. :O
Besides what's 1/3 or .001, you only do it once, sip some coffee ;-))
I actually did a lot of rehearsals and I can't notice the difference, in terms of the time spent.
But I am a perfectionist (that's why I can't finish my projects... a classic!) and I know that if I leave something there, settle for something there, pretend I don't see it that way... eventually the difference you'll see.
Optimizing your code is critical for any project...
-
I actually did a lot of rehearsals and I can't notice the difference, in terms of the time spent.
But I am a perfectionist (that's why I can't finish my projects... a classic!) and I know that if I leave something there, settle for something there, pretend I don't see it that way... eventually the difference you'll see.
Optimizing your code is critical for any project...
My philosophy is:
FIRST get it working, then get it working right THEN get it optimized.
Because we all know it's never going to be perfect unless it's math ;-))
(that's why I can't finish my projects... a classic!)
Really no sense in optimizing excrement ;-))
-
@krovit I have updated the code for pipecom here:
https://www.qb64.org/forum/index.php?topic=3168.0 (https://www.qb64.org/forum/index.php?topic=3168.0)
There was a bug that caused data duplication.
-
@krovit I have updated the code for pipecom here:
https://www.qb64.org/forum/index.php?topic=3168.0 (https://www.qb64.org/forum/index.php?topic=3168.0)
There was a bug that caused data duplication.
Ok, thank you!