Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

WOW6432Node detection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
VistaDB - 13 Jun 2007 01:32 GMT
OK, I know this has been discussed before.  I need to detect when I am
running on 64 bit windows, and write a specific key to the 32 bit node
for VS 2005 to load my plugin (I am 64 bit, it is 32 bit).

ManagementObjectSearcher mso = new ManagementObjectSearcher("SELECT *
FROM Win32_OperatingSystem"); //Win32_ComputerSystem");
ManagementObjectCollection qc =  mso.Get();

Console.WriteLine("OSArchitecture: " +
mo["OSArchitecture"].ToString());

That is the C# code to get the OSArchitecture from the WMI interface.

My question is, why does it blow up on my Windows XP 64 bit install?
It appears to work fine under 64 bit Vista - I get a response of
either 32 bit or 64 bit as I would expect.
Willy Denoyette [MVP] - 13 Jun 2007 13:28 GMT
> OK, I know this has been discussed before.  I need to detect when I am
> running on 64 bit windows, and write a specific key to the 32 bit node
[quoted text clipped - 10 lines]
>
> My question is, why does it blow up on my Windows XP 64 bit install?

It "blows up" because, this property is only available on Vista and higher,
read the WMI docs in msdn before using it's class properties.
Note that it's not important to know whether you run on 64 or 32 bit OS,
what's important is to know whether you run a 64 bit application natively or
whether you run a 32 bit application under WOW64.
You can check whether you are running under wow64, by calling the
"IsWow64Process" API  from Kernel32.dll via PInvoke. However, be carefull,
read the API description carefully, using this API can be tricky,.

Willy.
VistaDB - 14 Jun 2007 10:13 GMT
> You can check whether you are running under wow64, by calling the
> "IsWow64Process" API  from Kernel32.dll via PInvoke. However, be carefull,
> read the API description carefully, using this API can be tricky,.

I can't use that.  I MUST be 100% managed - no DLL imports.  Same app
runs under Mono right now and I don't want to break it just for this
silly call.
Willy Denoyette [MVP] - 14 Jun 2007 11:28 GMT
>> You can check whether you are running under wow64, by calling the
>> "IsWow64Process" API  from Kernel32.dll via PInvoke. However, be
[quoted text clipped - 4 lines]
> runs under Mono right now and I don't want to break it just for this
> silly call.

There is no such thing like 100% managed, if you need to know certain
details about the underlying Windows platform you will have to call into
Win32, whether you are doing it yourself, or whether the framework exposes
this doesn't matter, you will have to transition into unmanaged code.
Anyway, this "silly" call is to only way to know whether you are running "32
bit" code on Windows 64-bit., and using WMI for this is no solution, mono
doesn't expose this.

Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.