Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Nov 15, 2019 8:17 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Version of Windows
PostPosted: Wed Mar 23, 2011 10:38 am 
Offline

Joined: Fri Feb 29, 2008 5:25 pm
Posts: 557
How can I tell if the OS is Windows 64 bit or Windows 32 bit?

_________________
http://www.mupromo.com/?ref=4850
Support Indie Developers and Buy Their Products!


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 10:45 am 
Offline

Joined: Thu May 03, 2007 2:33 pm
Posts: 289
Have a look at GetNativeSystemInfo:
http://msdn.microsoft.com/en-us/library/ms724340(v=vs.85).aspx


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 2:35 pm 
Offline

Joined: Fri Feb 29, 2008 5:25 pm
Posts: 557
HOw do I use this?

_________________
http://www.mupromo.com/?ref=4850
Support Indie Developers and Buy Their Products!


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 3:41 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
If all you want to do is determine whether the OS is 64 bit, then this should work:

Dim Is64Bit As Boolean = System.IsFunctionAvailable("GetSystemWow64Directory", "kernel32.dll")


Is64Bit = True if Windows is 64 bit, else false.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 4:10 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
That by itself won't work. The function is available on 32 bit versions, it just always returns a non-zero result (ie., it fails on 32 bit systems). You have to both check that it is available and actually call it. I'd go with GetNativeSystemInfo.


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 4:45 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
timhare wrote:
That by itself won't work. The function is available on 32 bit versions, it just always returns a non-zero result (ie., it fails on 32 bit systems). You have to both check that it is available and actually call it. I'd go with GetNativeSystemInfo.


Ah, quite right. I was testing for a function that doesn't exist anyway on either platform (GetSystemWOW64Directory is one of those annoying functions with W and A variants.) So it always returned false on my 32 bit system.
Declare Function  GetSystemWow64DirectoryW Lib "kernel32"(nullBuff As Ptr, buffSize As Integer) As Integer
Dim nullMB As New MemoryBlock(0)
If GetSystemWow64DirectoryW(nullMB, 0) = 0 Then
MsgBox("32")
Else
MsgBox("64")
End If


This would work, I think.



PS:

Someone update the Windows Functionality Suite...

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 5:18 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
In case anyone is interested, the call to GetNativeSystemInfo is
function is64bit() as boolean
dim is64 as boolean

soft declare sub GetNativeSystemInfo lib "kernel32" (lpSystemInfo as Ptr)

if System.IsFunctionAvailable("GetNativeSystemInfo", "kernel32") then
dim mb as new memoryblock(36)
GetNativeSystemInfo(mb)
if mb.Int16Value(0) > 0 then is64 = true
end

return is64
end


Top
 Profile  
Reply with quote  
 Post subject: Re: Version of Windows
PostPosted: Wed Mar 23, 2011 8:08 pm 
Offline
Site Admin
User avatar

Joined: Fri Sep 30, 2005 9:35 am
Posts: 987
Location: South Portland, Maine
I wrote an article about this last month:

Detecting 64-bit Windows

_________________
Paul Lefebvre
Developer Evangelist
Xojo, Inc.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group