GetVersionEx & Windows 10

591 views
Skip to first unread message

Alex Eastwood

unread,
Mar 15, 2017, 6:47:06 AM3/15/17
to MapInfo-L
Hi MapInfo/MapBasic folks,

(using 32-bit MapInfo 15 and Windows 10)

Type OSVERSIONINFO
    dwOSVersionInfoSize
As integer
    dwMajorVersion
As integer
    dwMinorVersion
As integer
    dwBuildNumber
As integer
    dwPlatformId
As integer
    szCSDVersion
As String * 128
End Type

Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As integer

Used in a function:
Dim OSInfo as OSVersionInfo
Dim nRet As Integer

'Set the structure size
OSInfo.dwOSVersionInfoSize = 148    '
Len(OSInfo)
'Get the Windows version
iRet = GetVersionEx(OSInfo)

I need to write a function like above, as the behaviour of the GetVersionEx function has changed and you can't tell for sure whether the OS is 8, 8.1 or 10.

I can't find much online on how to use Windows functions from MapBasic, so does anyone have any useful documentation or could anyone provide some assistance on how to use something like GetProductInfo? I read up about GetProductInfo here.

Any help would be much appreciated, even just some code examples so I can work the rest out for myself.

Thanks and kind regards,

Alex
GIS Developer
London, UK

Nesh P.

unread,
Mar 17, 2017, 8:40:49 AM3/17/17
to MapInfo-L
I have answered also at http://gis.stackexchange.com/questions/232390/use-windows-function-getproductinfo-via-mapbasic

I have successfully implemented this solution.


enter image description here


Based on that I have created .NET assembly (*.dll).

After that all you need is to declare the method in your MapBasic application:


Declare Method OSName
    Class "nmiDotNet.MBOSinfo" 
    Lib "nmiDotNet.dll" () As String    


And you can call this method like simple function in MapBasic: OSName()

I customized output string to get names like this:



Windows 10 Professional Bit64 
Windows 8 Professional Bit64 
Windows 7 Enterprise Bit64 (Service Pack 1)
Windows 7 Enterprise Bit32 (Service Pack 1)
Windows XP Professional Bit32 (Service Pack 3)

Alex Eastwood

unread,
Mar 17, 2017, 9:00:35 AM3/17/17
to MapInfo-L
Hi Nesh,

yes thanks for your replies, cross-postng in GIS stack exchange as well since I didn't get any response here. I will have a look in to it when i get a chance!

Best,

Alex

Nesh P.

unread,
Mar 17, 2017, 9:18:15 AM3/17/17
to MapInfo-L
Don't forget to upvote and accept! ;)

I always upvote answers and posts of our dear friend Peter Horsbøll Møller, look how many points he has :)

Alex Eastwood

unread,
Mar 17, 2017, 12:11:39 PM3/17/17
to MapInfo-L
Ha, I have upvoted, was going to leave it until I've tried and implemented until I mark it as the accepted answer. Curious to see if there are any other responses/methods so feel like best to leave it without an accepted answer for the time being.

And yes, I'm waiting on our dear friend Peter to see what he has to say on the matter! (hint hint) To be fair he has always helped in the past and I imagine he also has a life outside of MapBasic that he is keen to get on with!

Peter Horsbøll Møller

unread,
Mar 18, 2017, 1:56:15 PM3/18/17
to mapi...@googlegroups.com

Thanks guys.

This time I kept quiet for a good reason:

I had no answer at all J

 

Enjoy your weekends!

 

Peter Horsbøll Møller

Pitney Bowes

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to
mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Reply all
Reply to author
Forward
0 new messages