的Windows获取架构(32/64位版本) [英] Getting Architecture of Windows (32/64 bit version)
问题描述
我有一个小问题:
IM特林得到操作系统的架构,这个问题是我的编程语言犯规支持这样的功能。因此我需要阅读该信息形成一个Windows动态链接库(比如kernel32.dll)结果
我曾尝试与功能,以获得相关信息 GetNativeSystemInfo / GetVersionEx /的GetSystemInfo
。结果
遗憾的是我没能拿到架构:/
im tring to get the architecture of the OS, the problem is my programming language doesnt support such functions. Therefore i need to read this information form an windows dll (like kernel32.dll)
i did try to get the infos with the functions GetNativeSystemInfo/GetVersionEx/GetSystemInfo
.
Unfortunately i were not able to get the architecture :/
是否还有其他一些功能来读取任何Windows动态链接库的架构?结果
(它dosnt需要KERNEL32它可以是任何的DLL,但它必须在赢的xp +存在)
Are there some other Functions to read the architecture in any windows dll?
(it dosnt need to be kernel32 it can be any dll but it must exists in win xp+)
随着信息:使用古普塔IM(SQLWindows /团队devoloper)
As info: im using Gupta (SQLWindows/Team devoloper)
EDIT1:
typedef struct _SYSTEM_INFO {
union {
DWORD dwOemId;
struct {
WORD wProcessorArchitecture;
WORD wReserved;
} ;
} ;
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
} SYSTEM_INFO;
这就是从 MSDN ,我试着用10和12的参数来调用该函数
(古普塔dosnt支持结构)。结果
在32位我得到:结果
thats the info from MSDN, i tried to call this Function with with 10 and 12 Parameters
(Gupta dosnt support structs).
On 32Bit i get:
在64位我得到:结果
on 64Bit i get:
我每次都遇到一个 0
OEMID在32位?或者更好的是OEMID everytiem弥漫在Windows的64位版本?
do i get every time a 0
OemID on 32 bit? or better is the OemID everytiem filled on 64bit version of windows?
THX的帮助!
电贺结果
AURO
Greets
Auro
推荐答案
的 GetNativeSystemInfo
肯定是使用的功能。如果你的应用程序是一个原生的64位应用程序, GetNativeSystemInfo
相同的 的GetSystemInfo
;否则,如果它WOW64下运行时,它就会返回真系统性能,即使是在一个模拟的32位的环境下运行。
GetNativeSystemInfo
is definitely the function to use. If your app is a native 64-bit app, GetNativeSystemInfo
is the same as GetSystemInfo
; otherwise, if it runs under WOW64, it will return the true system properties, even if it is run in an emulated 32-bit environment.
GetNativeSystemInfo
填补了的 结构, wProcessorArchitecture
成员,其中=nofollow的> SYSTEM_INFO告诉你系统是否为32比特(大概
PROCESSOR_ARCHITECTURE_INTEL
)或64位(大概 PROCESSOR_ARCHITECTURE_AMD64
)。
GetNativeSystemInfo
fills a SYSTEM_INFO
structure, the wProcessorArchitecture
member of which tells you whether the system is 32-bit (probably PROCESSOR_ARCHITECTURE_INTEL
) or 64-bit (probably PROCESSOR_ARCHITECTURE_AMD64
).
如果你的语言没有为这场比赛的胜利API函数的包装,使用它,你可以使用调用LoadLibrary
和 GetProcAddress的
像往常一样,和你需要定义当然 SYSTEM_INFO
结构。
If your language does not have a wrapper for this Win API function, to use it, you can employ LoadLibrary
and GetProcAddress
as usual, and you need to define the SYSTEM_INFO
structure, of course.
我会定义
typedef struct _SYSTEM_INFO {
WORD wProcessorArchitecture;
WORD wReserved;
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
} SYSTEM_INFO;
然后 wProcessorArchitecture = 0
A(普通)32位系统,以及 wProcessorArchitecture = 9
上一个(上常见)64位系统。这些只是常量 PROCESSOR_ARCHITECTURE_INTEL
和 PROCESSOR_ARCHITECTURE_AMD64
,分别为。这些都是常见的32位和64位架构。 PROCESSOR_ARCHITECTURE_IA64 = 6
稍微少见,如确实是 PROCESSOR_ARCHITECTURE_UNKNOWN = 65535
。
Then wProcessorArchitecture = 0
on a (common) 32-bit system, and wProcessorArchitecture = 9
on a (common) 64-bit system. These are just the constants PROCESSOR_ARCHITECTURE_INTEL
and PROCESSOR_ARCHITECTURE_AMD64
, respectively. These are the common 32-bit and 64-bit architectures. PROCESSOR_ARCHITECTURE_IA64 = 6
is slightly more uncommon, as is surely PROCESSOR_ARCHITECTURE_UNKNOWN = 65535
.
是的,我看到你的问题。在C,联盟
意味着你选择的有一个的在时间的选项。也就是说,该结构可以是
Yes, I see your problem. In C, union
means that you choose one of the options at a time. That is, the structure is either
DWORD dwOemId;
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
或
WORD wProcessorArchitecture;
WORD wReserved;
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
由于一个DWORD由尽可能多的字节(4),为两个单词(2×2),该替代品是adressing(和命名)的仅有两种方式的整体结构的数据。在我们的例子中,我们更感兴趣的是 wProcessorArchitecture
字甚则增大 dwOemId
的wProcessorArchitecture
和完全无趣的 wReserved
的话。
Because one DWORD consists of as many bytes (4) as two words (2×2), the alternatives are just two ways of adressing (and naming) the data of the entire structure. In our case, we are more interested in the wProcessorArchitecture
word rather then the augment dwOemId
of wProcessorArchitecture
and the utterly uninteresting wReserved
words.
这篇关于的Windows获取架构(32/64位版本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!