2

I develop a MapInfo-based GIS and I need to be able to determine the Windows OS of a given user. So far we have used a Windows function GetVersionEx (kernel32 library) to do this but the function doesn't behave properly from Windows 8.1 onwards...unless you do Application Manifesting which I'd rather not mess around with unless absolutely necessary.

As an alternative I found a post suggesting to use GetProductInfo instead but I don't know how to set this up in MapBasic.

The GetVersionEx function is first defined like this:

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

(OSVersionInfo documentation here)

And then called in MapBasic:

Dim OSInfo as OSVersionInfo
Dim nRet,iMaj_Version As Integer
'Set the structure size
OSInfo.dwOSVersionInfoSize = 148 'Len(OSInfo)
'Get the Windows version
iRet = GetVersionEx(OSInfo)
'get values e.g.:
iMaj_Version = OSInfo.dwMajorVersion

so it will be similar to this I expect...but I don't know how the new function needs to be defined or how I then get the output in to a MapBasic variable.

Finally, we are using the 32-bit version of MapInfo so for the time being I'm not interested in potential help/solutions for the 64-bit version.

asked Mar 16, 2017 at 17:02

1 Answer 1

3

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)
answered Mar 16, 2017 at 17:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.