Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
Hello friends,

I need VB.net solutions (in dotnet 2.0) for the following features:
a) Detect OS architecture - x86 or x64
b) Read registry key from 64 bit reg key and Wow6432 nodes as well base don system architecture.

Well i get the code solution for the above features but all were in C# and above dotnet 3.5 or newer frameworks.

My limitation is dotnet 2.0. Please if somebody has got any available solutions, please do help with some code snippet.

What I have tried:

For sys architecture i tried this, but getting error with

VB
Public Function Is64BitOS() As Boolean
    Using p As Process = Process.GetCurrentProcess()
        Dim retVal As Boolean
        Return (IntPtr.Size = 8 OrElse (IsWow64Process IsNot Nothing AndAlso IntPtr.Size = 4 AndAlso IsWow64Process(p.Handle, retVal) AndAlso retVal))
    End Using
End Function


And for Read registry key, based on sys architecture i am planning to hardcode the wow6432 node path accordingly. personally i dont like this approach, but if somebody has got a better solution then do let me know.
Posted
Updated 24-Jan-19 2:29am
Comments
CHill60 23-Jan-19 8:17am    
So what was the error you got?

 
Share this answer
 
v2
Reading 64/32-bit registry keys in .NET 2.0 will require some P/Invoke calls:
How to read the 64 bit registry from a 32 bit application or vice versa | Rhyous[^]

The code in that post is in C#, but it should be possible to convert it to VB.NET; otherwise, you could always create a C# assembly with that code, and call it from your VB.NET application.

NB: Mainstream support for .NET 2.0 SP2 ended in 2011. Extended support ended in 2016. You really need to look at updating to a newer version if at all possible. :)
 
Share this answer
 
Comments
Maciej Los 24-Jan-19 8:31am    
Nice link!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900