Author Topic: System Info of windows  (Read 6291 times)

0 Members and 1 Guest are viewing this topic.

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
System Info of windows
« 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!
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

FellippeHeitor

  • Guest
Re: System Info of windows
« Reply #1 on: October 30, 2020, 05:46:51 am »
Sounds like a job for @SpriggsySpriggs!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: System Info of windows
« Reply #2 on: October 30, 2020, 09:19:09 am »
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...

Code: [Select]
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"
« Last Edit: October 30, 2020, 09:32:20 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: System Info of windows
« Reply #3 on: October 30, 2020, 04:41:33 pm »
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.

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: System Info of windows
« Reply #4 on: October 30, 2020, 07:03:43 pm »
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.

Code: QB64: [Select]
  1.  
  2. DECLARE LIBRARY ".\pipecom"
  3.     FUNCTION pipecom$ (cmd AS STRING)
  4.  
  5. ver = MID$(pipecom("ver"), 2)
  6. PRINT ver
« Last Edit: November 01, 2020, 06:16:11 pm by SpriggsySpriggs »
Shuwatch!

FellippeHeitor

  • Guest
Re: System Info of windows
« Reply #5 on: October 30, 2020, 07:13:49 pm »
Important reminder: once compiled, the .h file doesn't have to be shipped with your exe, if that's a concern.

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: System Info of windows
« Reply #6 on: October 31, 2020, 05:15:11 am »
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...

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: System Info of windows
« Reply #7 on: October 31, 2020, 07:14:42 am »
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!
Programming isn't difficult, only it's  consuming time and coffee

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: System Info of windows
« Reply #8 on: October 31, 2020, 07:35:22 am »
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!
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: System Info of windows
« Reply #9 on: October 31, 2020, 11:10:44 am »
Quote
"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

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: System Info of windows
« Reply #10 on: November 01, 2020, 05:46:04 pm »
@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
Shuwatch!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: System Info of windows
« Reply #11 on: November 01, 2020, 06:11:30 pm »
Have you checked Wiki:
https://www.qb64.org/wiki/ENVIRON$

FellippeHeitor

  • Guest
Re: System Info of windows
« Reply #12 on: November 01, 2020, 06:15:30 pm »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: System Info of windows
« Reply #13 on: November 01, 2020, 06:25:01 pm »
Man if it's not in here?
Code: QB64: [Select]
  1.   i = i + 1
  2.   setting$ = ENVIRON$(i) ' get a setting from the list
  3.   PRINT setting$
  4.   IF i MOD 20 = 0 THEN PRINT "Press a key": SLEEP: CLS
  5. LOOP UNTIL setting$ = ""
  6.  

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: System Info of windows
« Reply #14 on: November 02, 2020, 12:53:58 am »
Quick question, what do you need the windows version for?