Detection of current version 'Windows' Operating system using Studio 5 -- sys(7) alternative

Paul Mulroney pmulroney at logicaldevelopments.com.au
Mon Nov 5 21:45:52 EST 2018


Hi Doug,

Try this:

Calculate vsCmd as 'systeminfo'
Launch program [vsCmd] Returns vsResult (Do not quit Omnis)     ;; Returns a list of key/value pairs
;  | findstr /B /C:"OS Name" /C:"OS Version"     ;; alternatively, could just reduce the result down using this

Do vlResult.$define(vsKey,vsValue)
Calculate vsResult as replaceall(vsResult,kLf,'')     ;; Result has line breaks of CR/LF.  Remove the LFs, then use the CR as the delimiter for each line.
While len(vsResult)     ;; Split the result into a key/value pair liust
	Calculate vsLine as strtok('vsResult',kCr)
	Calculate vsKey as trim(strtok('vsLine',':'))     ;; Strip leading/trailing spaces.
	Calculate vsValue as trim(vsLine)     ;; More important for this - lots of embedded spaces to make it line up nicely on the command line.
	Do vlResult.$add(vsKey,vsValue)
End While

Breakpoint {vlResult}

I couldn't get the findstr part to work quickly, probably something to do with embedded quotes.  Therefore you need to search the results for your "OS Name"/"OS Version" keys.

Regards,
Paul.


> On 6 Nov 2018, at 10:20 am, Doug Easterbrook <doug at artsman.com> wrote:
> 
> hi paul —
> 
> my code is similar —and based off sys (7);    This is the mac part.
> 
> itrs not 100% accurate, but close.
> 
> 
> what I really need is to know 100% for sure that the machine I’m running on is windows8, windows 8.1 or windows 10  — using some function in studio 5.   and sys(7) does not work for the higher operating system versions on windows.
> 
> I was hoping somebody had  done something with register dll/call dll     or had a way to get a result out of a system call - or reading theregistry.
> 
> eg, I’ve seen that this could work
> CString osname = GetStringFromReg(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName”);
> 
> or this command in dos
> systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
> 
> 
> 
> I”m not adept at getting the registerdll thing — so if somebody has done it… it would be great. 
> 


I bought my friend an elephant for his room. He said “Thanks” I said “Don’t mention it”
-- 
Paul W. Mulroney                                            We Don't Do Simple Pty Ltd 
pmulroney at logicaldevelopments.com.au       Trading as Logical Developments
www.logicaldevelopments.com.au                   ACN 161 009 374 
Ph: +61 8 9458 3889                                       86 Coolgardie Street
                                                                         BENTLEY  WA  6102






More information about the omnisdev-en mailing list