在PowerBuilder中确定操作系统类型。

时间:2012-10-08 08:40:20

标签: powerbuilder

如何在PowerBuilder中确定操作系统是64位还是32位?

是否可以使用GetEnvironment获取它?

3 个答案:

答案 0 :(得分:8)

检查环境变量很简单,但它不是防弹的,因为用户可以重新定义该值。

更强大的方法是检查当前的Powerbuilder进程是否在WOW64模式(32位仿真模式)下运行。

[Local external definitions]
FUNCTION long IsWow64Process(long hwnd, ref  boolean Wow64Process) &
    LIBRARY "Kernel32.DLL"

FUNCTION long GetCurrentProcess ()  LIBRARY "KERNEL32.DLL"

[Powerscript]
boolean wow64 =false
IsWow64Process(GetCurrentProcess(), wow64)
MessageBox("Running in 64b env", wow64)

答案 1 :(得分:2)

GetEnvironment可以通过其CPUType属性提供有关cpu的一些信息,但它只返回平台类型(alpha,mips,pentium,...)。

您可以通过使用ProgramFiles(x86) / GetContextService并将环境变量设置为查询的上下文关键字,从仅在64b平台上定义的环境(例如GetContextKeywords)测试一些非凡的值:

string ls_vals[], ls_val, ls_env = "ProgramFiles(x86)" /*name of the env variable to query*/
ContextKeyword lcxk_base

GetContextService("Keyword", lcxk_base)
lcxk_base.GetContextKeywords(ls_env, ls_vals[])
if upperbound(ls_vals[]) > 0 then
   ls_val = ls_vals[1]
else
   ls_val = "*undefined*" //it is 32b
end if

messagebox ("architecture", ls_val)

我首先会建议在shell 64b中测试PROCESSOR_ARCHITECTURE环境变量,即AMD64,但似乎PB可执行文件得到x86。 ..

答案 2 :(得分:0)

您可以使用Roland Smith网站上的免费代码。

http://www.topwizprogramming.com/freecode_osversion.html

“此程序返回有关操作系统版本的信息。它返回操作系统名称,版本和Service Pack。它还具有从.dll和.exe文件返回版本字符串的功能。”

相关问题