Home All Groups Group Topic Archive Search About

How I can find out on which platform I am running (32/64 bits)?

Author
22 Dec 2006 6:03 AM
sajin
Hi All,

I am building a windows application in VB .Net 2005 , and for deploying
the application i need to run some exe's if it is 32 bits and some
other exe's for 64 bits

Can anyone tell me how can i findout this using VB .Net


Thanks in advance
-Sajin

Author
22 Dec 2006 12:33 PM
Newbie Coder
I don't have the code for you, but you will need to use the GetVersionEx API
with the OSVERSIONINFOEX Structure

Use the Environment namespeace to get the basic OS version
(http://support.microsoft.com/kb/304289/en-us/http://support.microsoft.com/k
b/304722/en-us) & pass to the above API

You can then find out if its a server/workstation/service pack level...

I hope this is of some use

Newbie Coder


Show quoteHide quote
"sajin" <sa***@iprlab.com> wrote in message
news:1166767402.585769.204870@73g2000cwn.googlegroups.com...
> Hi All,
>
> I am building a windows application in VB .Net 2005 , and for deploying
> the application i need to run some exe's if it is 32 bits and some
> other exe's for 64 bits
>
> Can anyone tell me how can i findout this using VB .Net
>
>
> Thanks in advance
> -Sajin
>
Author
22 Dec 2006 3:58 PM
ImageAnalyst
Some sample code is here:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=39625&lngWId=1
on Planet Source Code.  It's VB6 though.  I don't know of anything in
vb.net to get that - there may be, but I personally am just unaware of
any.
Regards,
ImageAnalyst

sajin wrote:
Show quoteHide quote
> Hi All,
>
> I am building a windows application in VB .Net 2005 , and for deploying
> the application i need to run some exe's if it is 32 bits and some
> other exe's for 64 bits
>
> Can anyone tell me how can i findout this using VB .Net
>
>
> Thanks in advance
> -Sajin
Author
22 Dec 2006 5:54 PM
Newbie Coder
But with the PSC screen from that code you see that it says things like
Professional/home... That isn't actually breaking it down far enough, is it?
Only the 64 bit is of use there though.

Lets rip the code to pieces & see if we can do a simple translation. Need to
get my VS 6 Enterprise discs out 'cos the upgrade feature in VB.NET ain't
all that, is it?

Newbie Coder
Author
22 Dec 2006 7:04 PM
Newbie Coder
Ok. So here is the answer

'IsWow64Process' API function is declared in Kernall32.dll from XP onwards

' Import
Imports System.Diagnostics

' Declaration
Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProcess As
Int32, ByRef Wow64Process As Boolean) As Int32

' Function
    Private Function Is64Bit() As Boolean
        Dim proc As Process = Process.GetCurrentProcess
        Dim Wow64Process As Boolean
        Try
            Return IsWow64Process(proc.Id, Wow64Process) <> 0
        Catch ex As Exception
            Return False
        End Try
    End Function

' Usage:
MessageBox.Show(Is64Bit.ToString)

I hope this helps,

Newbie Coder
Author
23 Dec 2006 7:48 PM
ImageAnalyst
You didn't look at the whole screenshot.  Look at the next line below
the professional/home.  It says "64 bit system: False".  Presumably it
would say true if you had a 64 bit system, so there must be a way in
the code to detect that.
ImageAnalyst.

Newbie Coder wrote:
Show quoteHide quote
> But with the PSC screen from that code you see that it says things like
> Professional/home... That isn't actually breaking it down far enough, is it?
> Only the 64 bit is of use there though.
>
> Lets rip the code to pieces & see if we can do a simple translation. Need to
> get my VS 6 Enterprise discs out 'cos the upgrade feature in VB.NET ain't
> all that, is it?
>
> Newbie Coder
Author
24 Dec 2006 1:46 AM
Newbie Coder
I saw that, downloaded the VB 6 code, updated it to VB.NET & posted above
your last post

Please read my last post before this one

Newbie Coder
Author
26 Dec 2006 2:52 PM
ImageAnalyst
Good!  Nice contribution!  I'm sure it will be useful to many in the
future as 64 bit systems become more commonplace.
ImageAnalyst.
(By the way, your prior post wasn't there when I replied via Google
Discussion Groups even though you posted it a day before mine.  Maybe
there is a lag somewhere.)

Newbie Coder wrote:
Show quoteHide quote
> I saw that, downloaded the VB 6 code, updated it to VB.NET & posted above
> your last post
>
> Please read my last post before this one
>
> Newbie Coder
Author
29 Dec 2006 8:14 AM
sajin
Hi All,

I got it through the registry entry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Environment
Read the Key value "PROCESSOR_ARCHITECTURE"

For 32bit it shows - x86
For 64bit it shows-  AMD64

Thanks
Sajin
ImageAnalyst wrote:
Show quoteHide quote
> Good!  Nice contribution!  I'm sure it will be useful to many in the
> future as 64 bit systems become more commonplace.
> ImageAnalyst.
> (By the way, your prior post wasn't there when I replied via Google
> Discussion Groups even though you posted it a day before mine.  Maybe
> there is a lag somewhere.)
>
> Newbie Coder wrote:
> > I saw that, downloaded the VB 6 code, updated it to VB.NET & posted above
> > your last post
> >
> > Please read my last post before this one
> >
> > Newbie Coder
Author
29 Dec 2006 5:34 PM
Newbie Coder
That's cool - Nice Work

Newbie Coder

"sajin" <sa***@iprlab.com> wrote in message
news:1167380095.654710.297340@73g2000cwn.googlegroups.com...
> Hi All,
>
> I got it through the registry entry
>
>
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Environme
nt
Show quoteHide quote
> Read the Key value "PROCESSOR_ARCHITECTURE"
>
> For 32bit it shows - x86
> For 64bit it shows-  AMD64
>
> Thanks
> Sajin
> ImageAnalyst wrote:
> > Good!  Nice contribution!  I'm sure it will be useful to many in the
> > future as 64 bit systems become more commonplace.
> > ImageAnalyst.
> > (By the way, your prior post wasn't there when I replied via Google
> > Discussion Groups even though you posted it a day before mine.  Maybe
> > there is a lag somewhere.)
> >
> > Newbie Coder wrote:
> > > I saw that, downloaded the VB 6 code, updated it to VB.NET & posted
above
> > > your last post
> > >
> > > Please read my last post before this one
> > >
> > > Newbie Coder
>
Author
29 Dec 2006 7:23 PM
Chris Mullins
There are all these complex answers that I see people giving. There's a much
easier way:

public static bool IsRunningOnWin64()
{
    return (IntPtr.Size == 8);
}

In VB this would be:

public shared function IsRunningOnWin64() as boolean
    return (IntPtr.Size = 8)
end function

This won't tell you if you're running in WOW on Win64, but it'll let you
know if your app is running in 32 or 64 bit land.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins

Show quoteHide quote
"sajin" <sa***@iprlab.com> wrote in message
news:1166767402.585769.204870@73g2000cwn.googlegroups.com...
> Hi All,
>
> I am building a windows application in VB .Net 2005 , and for deploying
> the application i need to run some exe's if it is 32 bits and some
> other exe's for 64 bits
>
> Can anyone tell me how can i findout this using VB .Net
>
>
> Thanks in advance
> -Sajin
>
Author
29 Dec 2006 10:17 PM
Newbie Coder
Found another way for you

Import the SYSTEM.MANAGEMENT.DLL

' In form Class

Imports System.Management

    Dim mos As ManagementObjectSearcher = New
ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
    Dim mo As ManagementObject

    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnGet.Click
        For Each mo In mos.Get
            txtSystemType.Text = mo("systemtype").ToString
        Next
    End Sub


That will return the answer you require too

I have attached the project to this post. So, if you use Outlook Express you
can download the project zip

I hope this also helps,

Newbie Coder

[attached file: System Type (32 or 64 Bit).zip]
Author
29 Dec 2006 11:13 PM
Chris Mullins
Using WMI may have far reaching implications.

I believe that a limited access account won't have sufficient right to run
the WMI select.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins

Show quoteHide quote
"Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message
news:eW5Jrb5KHHA.1240@TK2MSFTNGP03.phx.gbl...
> Found another way for you
>
> Import the SYSTEM.MANAGEMENT.DLL
>
> ' In form Class
>
> Imports System.Management
>
>    Dim mos As ManagementObjectSearcher = New
> ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
>    Dim mo As ManagementObject
>
>    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles btnGet.Click
>        For Each mo In mos.Get
>            txtSystemType.Text = mo("systemtype").ToString
>        Next
>    End Sub
>
>
> That will return the answer you require too
>
> I have attached the project to this post. So, if you use Outlook Express
> you
> can download the project zip
>
> I hope this also helps,
>
> Newbie Coder
>
>
>
Author
30 Dec 2006 3:08 AM
Mudhead
What's wrong with this?

Debug.WriteLine(My.Computer.Info.OSFullName)
Debug.WriteLine(My.Computer.Info.OSPlatform)
Debug.WriteLine(My.Computer.Info.OSVersion)



Show quoteHide quote
"Chris Mullins" <cmull***@yahoo.com> wrote in message
news:e4GcF85KHHA.2140@TK2MSFTNGP03.phx.gbl...
> Using WMI may have far reaching implications.
>
> I believe that a limited access account won't have sufficient right to run
> the WMI select.
>
> --
> Chris Mullins, MCSD.NET, MCPD:Enterprise
> http://www.coversant.net/blogs/cmullins
>
> "Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message
> news:eW5Jrb5KHHA.1240@TK2MSFTNGP03.phx.gbl...
>> Found another way for you
>>
>> Import the SYSTEM.MANAGEMENT.DLL
>>
>> ' In form Class
>>
>> Imports System.Management
>>
>>    Dim mos As ManagementObjectSearcher = New
>> ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
>>    Dim mo As ManagementObject
>>
>>    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles btnGet.Click
>>        For Each mo In mos.Get
>>            txtSystemType.Text = mo("systemtype").ToString
>>        Next
>>    End Sub
>>
>>
>> That will return the answer you require too
>>
>> I have attached the project to this post. So, if you use Outlook Express
>> you
>> can download the project zip
>>
>> I hope this also helps,
>>
>> Newbie Coder
>>
>>
>>
>
>
Author
30 Dec 2006 3:35 AM
Newbie Coder
User never specified VB.NET 2005 code
Author
30 Dec 2006 3:56 AM
Mudhead
What??????????????????????
> User never specified VB.NET 2005 code
>
>

Sure he did. Read his post below. I see VB.Net 2005 is listed there. Don't
you?

Show quoteHide quote
>Hi All,

>I am building a windows application in VB .Net 2005 , and for deploying
>the application i need to run some exe's if it is 32 bits and some
>other exe's for 64 bits


>Can anyone tell me how can i findout this using VB .Net


>Thanks in advance
>-Sajin




"Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message
news:emHmBN8KHHA.2236@TK2MSFTNGP02.phx.gbl...
> User never specified VB.NET 2005 code
>
>
Author
30 Dec 2006 3:46 AM
Newbie Coder
Found another way for you using WMI:

Add a reference to the SYSTEM.MANAGEMENT.DLL

Then add this Import:

' Import

Imports System.management

' Add a Textbox called 'txtSystemType' & a button called 'btnGet'. Now paste
in the following code:

    Dim mos As ManagementObjectSearcher = New
ManagementObjectSearcher("SELECT * FROM Win32_Processor")
    Dim mo As ManagementObject

    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnGet.Click
        For Each mo In mos.Get
            txtSystemType.Text = mo("AddressWidth").ToString & " bit"
        Next
    End Sub

This will then return 32 or 64 & 'bit' to the textbox

I hope this also helps,

Newbie Coder
Author
30 Dec 2006 1:16 PM
Mudhead
Opps...Ignore this post.

Show quoteHide quote
"Mudhead" <noth***@yourhouse.com> wrote in message
news:%23t571$7KHHA.4000@TK2MSFTNGP06.phx.gbl...
> What's wrong with this?
>
> Debug.WriteLine(My.Computer.Info.OSFullName)
> Debug.WriteLine(My.Computer.Info.OSPlatform)
> Debug.WriteLine(My.Computer.Info.OSVersion)
>
>
>
> "Chris Mullins" <cmull***@yahoo.com> wrote in message
> news:e4GcF85KHHA.2140@TK2MSFTNGP03.phx.gbl...
>> Using WMI may have far reaching implications.
>>
>> I believe that a limited access account won't have sufficient right to
>> run the WMI select.
>>
>> --
>> Chris Mullins, MCSD.NET, MCPD:Enterprise
>> http://www.coversant.net/blogs/cmullins
>>
>> "Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message
>> news:eW5Jrb5KHHA.1240@TK2MSFTNGP03.phx.gbl...
>>> Found another way for you
>>>
>>> Import the SYSTEM.MANAGEMENT.DLL
>>>
>>> ' In form Class
>>>
>>> Imports System.Management
>>>
>>>    Dim mos As ManagementObjectSearcher = New
>>> ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
>>>    Dim mo As ManagementObject
>>>
>>>    Private Sub btnGet_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles btnGet.Click
>>>        For Each mo In mos.Get
>>>            txtSystemType.Text = mo("systemtype").ToString
>>>        Next
>>>    End Sub
>>>
>>>
>>> That will return the answer you require too
>>>
>>> I have attached the project to this post. So, if you use Outlook Express
>>> you
>>> can download the project zip
>>>
>>> I hope this also helps,
>>>
>>> Newbie Coder
>>>
>>>
>>>
>>
>>
>
>