請問如何判斷 MS-Windows 是 32 位元或 64 位元 ? |
答題得分者是:taishyang
|
pcboy
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
|
taishyang
站務副站長 ![]() ![]() ![]() ![]() ![]() ![]() 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
pcboy
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
在 Windows XP x86 + Delphi 7 編譯測試 OK
編譯出來的程式碼拿去 Windows 7 x64 測試 OK [code delphi] function Is64BitOS: Boolean; type TIsWow64Process = function(Handle:THandle; var IsWow64 : BOOL) : BOOL; stdcall; var hKernel32 : Integer; IsWow64Process : TIsWow64Process; IsWow64 : BOOL; begin // we can check if the operating system is 64-bit by checking whether // we are running under Wow64 (we are 32-bit code). We must check if this // function is implemented before we call it, because some older versions // of kernel32.dll (eg. Windows 2000) don't know about it. // see http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx Result := False; hKernel32 := LoadLibrary('kernel32.dll'); if (hKernel32 = 0) then RaiseLastOSError; @IsWow64Process := GetProcAddress(hkernel32, 'IsWow64Process'); if Assigned(IsWow64Process) then begin IsWow64 := False; if (IsWow64Process(GetCurrentProcess, IsWow64)) then begin Result := IsWow64; end else RaiseLastOSError; end; FreeLibrary(hKernel32); end; [/code] http://stackoverflow.com/questions/601089/detect-whether-current-windows-version-is-32-bit-or-64-bit
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
pcboy
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
在 Windows XP x86 + VC++ 2008 編譯測試 OK
編譯出來的程式碼拿去 Windows 7 x64 測試 OK [code cpp] // VC 2008 // http://msdn.microsoft.com/en-us/library/ms684139 #include #include typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); LPFN_ISWOW64PROCESS fnIsWow64Process; BOOL IsWow64() { BOOL bIsWow64 = FALSE; //IsWow64Process is not available on all supported versions of Windows. //Use GetModuleHandle to get a handle to the DLL that contains the function //and GetProcAddress to get a pointer to the function if available. fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( GetModuleHandle(TEXT("kernel32")),"IsWow64Process"); if(NULL != fnIsWow64Process) { if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64)) { //handle error } } return bIsWow64; } void main() { if(IsWow64()) printf("The process is running under WOW64.\n"); else printf("The process is not running under WOW64.\n"); system("PAUSE"); } [/code]
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |