PowerBuilder Get Osbit running a 32-bit or 64-bit version of Windows
you can use the Windows API to determine the operating system architecture. Here is some sample code that you can use in PowerBuilder 10.5 to determine the operating system architecture
This code calls the GetNativeSystemInfo Windows API function to retrieve information about the system architecture. It then determines whether the operating system is 32-bit or 64-bit, and displays a message box with the result. Note that this code only works on Windows operating systems, and may not work on other platforms.
SYSTEM_INFO
is a structure in the Windows API that contains information about the current computer system. It is defined in the “WinNT.h” header file and contains the following members:
wProcessorArchitecture
: An integer value that specifies the processor architecture of the system. This value can be one of the following:PROCESSOR_ARCHITECTURE_INTEL
(0): The system has an x86 processor.PROCESSOR_ARCHITECTURE_IA64
(6): The system has an Intel Itanium processor.PROCESSOR_ARCHITECTURE_AMD64
(9): The system has an x64 processor.
wReserved
: This member is reserved for future use and should be set to 0.dwPageSize
: The page size and allocation granularity of the system, in bytes.lpMinimumApplicationAddress
: A pointer to the lowest memory address accessible to applications and dynamic-link libraries (DLLs).lpMaximumApplicationAddress
: A pointer to the highest memory address accessible to applications and DLLs.dwActiveProcessorMask
: A mask that specifies the set of processors that are currently available for use.dwNumberOfProcessors
: The number of processors in the system.dwProcessorType
: An integer value that specifies the type of processor in the system.dwAllocationGranularity
: The allocation granularity of memory, in bytes.wProcessorLevel
: The level of the processor in the system.wProcessorRevision
: The revision number of the processor.
You can use the GetNativeSystemInfo()
function in the Windows API to retrieve a SYSTEM_INFO
structure containing information about the current system.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
// Define structure SYSTEM_INFO type SYSTEM_INFO from structure unsignedinteger wprocessorarchitecture unsignedinteger wreserved unsignedlong dwpagesize unsignedlong lpminimumapplicationaddress unsignedlong lpmaximumapplicationaddress unsignedlong dwactiveprocessormask unsignedlong dwnumberofprocessors unsignedlong dwprocessortype unsignedlong dwallocationgranularity unsignedinteger wprocessorlevel unsignedinteger wprocessorrevsion end type // Declare variables integer li_architecture ulong ul_platform // Call the GetNativeSystemInfo Windows API function function ulong GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo) library "kernel32.dll" SYSTEM_INFO ls_sysinfo GetNativeSystemInfo(ls_sysinfo) // Determine the operating system architecture li_architecture = ls_sysinfo.wProcessorArchitecture if li_architecture = 0 then ul_platform = 32 // 32-bit architecture else ul_platform = 64 // 64-bit architecture end if // Display the operating system architecture if ul_platform = 32 then MessageBox("Operating System Architecture", "This is a 32-bit version of Windows.") else MessageBox("Operating System Architecture", "This is a 64-bit version of Windows.") end if |
Good Luck!