Get OS Type if 32bit or 64bit in silverlight - silverlight-5.0

I have a Silverlight 5 application and needs to check the client side operating system type if it's 32bit or 64bit OS.
Environment Class dosen't help.
I used the code
//C# Code
var bitSize = IntPtr.Size * 8; // returns 32
But, it return 32 while the OS is Windows 7 Enterprise SP1 64 bit base on the system property.
START>Computer>System Properties>
What is wrong with my code.

Related

Start windows 64bit driver from 32bit app on 64bit windows

Is there a work around for StartService in a 32bit program to start a 64bit driver on windows 64bit?
The reason i need to do it from 32bit program is that i compile the program under 32bit and 64bit depending on the type of process I'm working with.

How to build 32 bits C++ CLR project in 64 bit OS

My OS is Windows 7, 64 bits.
In Visual Studio, I'm trying to build this C++ CLR project as 32 bits, but after I build it, when I run Dependency Walker on it, every system dll it uses (for example, kernel32) is of 64 bit, thus giving the error "Modules with different CPU types were found".
I've already set the platform option to Win32 (btw, is this right? I expected x86, is Win32 equivalent?).
I also checked that in Linker->Advanced->Target Machine is equal to MachineX86.
Is there anything else I could do to build it targeting 32 bits.
EDIT 1: Since HansPassant questioned the reliability of Dependency Walker, I checked the bitness using corflags.
Results are these:
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 0x10
ILONLY : 0
32BITREQ : 0
32BITPREF : 0
Signed : 0
According to this this answer, apparently the dll is targeting "Any CPU".
I targeted 32 bits already, why is this happening?

I have 64 bit OS (Win 7) but when I check the sizeof(pointer) it says 4 byte . Should it not be 8 byte for 64 bit OS

I have read many posts that for a 16 bit system the sizeof(ptr) should be 2 byte , for a 32 bit system sizeof(ptr) = 4 byte and for a 64 bit system sizeof(ptr) = 8 byte and it makes sense also but on my machine which has a 64 bit OS (4 GB RAM) its says the sizeof(ptr) = 4 byte . Can someone explains it to me. Thanks
The Intel CPUs have the ability to execute 16, 32 and 64-bit binaries. The question is: which were you testing?
Both Windows and Linux are available in 32 and 64-bit versions. The difference is that 32-bit cannot execute 64-bit binaries, whereas 64-bit can.
If (and only if) you have a 64-bit OS and a 64-bit-capable development system and you write a program and explicitly tell it to generate a 64-bit program then when you run it you will see 8 byte pointers.
You mentioned in the comments you're using Visual Studio. To setup this compiler to build 64bit solutions the following will work for Visual Studio 2010, 2012, and 2013. The steps below were taken from the Microsoft MSDN site.
Right click on your solution in the solution explorer.
Choose properties.
Click the Configuration Manager... in the upper right corner.
Click the drop down arrow under Active solution configuration
Choose New and enter a name for this configuration. i.e. Debug64 or Release64
Click the drop down arrow under Copy settings from and Choose Win32. Copying from Win32 will automatically update multiple settings to 64bit.
Click Ok.
Under Active solution platform choose New
Under the platform should be an option for x64. Select this and click Ok.
Click Close.
You should now be building for the x64 platform and your pointers will be size 8.
To change back to 32bit, open the configuration manager again and choose the correct Configuration and Platform.

MSI - Conditionally register DLL

I'm working on a .NET profiler (my project output is a DLL). I have built 2 DLLs (written in c++) : one will be loaded by x86 .NET processes and the other by x64 ones. I want to generate a single MSI (targetting x86 patforms) that checks whether the OS is 64bits or 32bits. and then registers the correct DLL i.e :
- Project output : - the_x64.DLL
- the_x86.DLL
- A single MSI that targets x86 machines : contains the 2 DLLs
- if the OS is 64 bits then both of the DLLs are registered
- if the OS is 32 bits then only the x86 dll is registered
Is that possible?
The MSI platform does not support mixed 32/64 bit installers. There are hacks to create 'hybrid' MSI's but it's not officially supported. The approach recommended by Microsoft is to create 2 or more MSI's ( common, 32bit provider, 64bit provider ) and then use a bootstrapper such as WiX Burn or InstallShield Suite Installers to provide a single install experience to the end user.

Credential manager for Vista/Windows 7

I have Credential manager implemented in VC++ which captures credentials during login process. It works well in XP/Vista/Windows 7 32 bit env. But is not working in 64 bit.
Any idea ?
Thanks in advance for any help
If you want your DLL to be loaded by a 64-bit process, your DLL has to be compiled for 64 bits.
If you want your DLL to be loaded by a 32-bit process, your DLL has to be compiled for 32 bits. This is true on both 64-bit Windows systems and 32-bit Windows systems.
John gave you a useful link, even though John's wording is wrong. An application (exe) which is built for 32 bits will run in 64 bit Windows, but it can only load 32-bit DLLs.
Did you build for a 64-bit platform in Visual Studio?
A Visual C++ application which is build for a 32-bit environment won't work directly in a 64 bit environment. And although applications will work using the WOW64 compatibility layer, DLLs must be 64-bit if they are to be loaded by a 64-bit operating system.
Since that is indeed the case here, you need to build your project for a 64-bit platform (Visual Studio 2005 and later have a 64-bit compiler).
See the link http://msdn.microsoft.com/en-us/library/ms185328.aspx for more details.