Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int __fastcall TF_Main::Is64BitOS()
- {
- // Necessite #include <windows.h>
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms684139%28v=vs.85%29.aspx
- // http://stackoverflow.com/questions/601089/detect-whether-current-windows-version-is-32-bit-or-64-bit
- typedef BOOL (WINAPI *tIsWow64Process)(HANDLE, PBOOL);
- static HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32.dll"));
- int IsWow64 = 0;
- hKernel32 = LoadLibrary("kernel32.dll");
- if (hKernel32 == 0)
- {
- // Probleme lors du chargement de kernel32.dll
- return(-1);
- }
- tIsWow64Process IsWow64Process = (tIsWow64Process) GetProcAddress(hKernel32, "IsWow64Process");
- if (IsWow64Process != NULL)
- {
- if (IsWow64Process(GetCurrentProcess(), &IsWow64))
- {
- FreeLibrary(hKernel32);
- return(IsWow64); // On est dans un environnement Win64
- }
- else
- {
- // Probleme lors de l'appel de IsWow64Process()
- FreeLibrary(hKernel32);
- return(-1);
- }
- }
- else
- {
- FreeLibrary(hKernel32);
- return(0); // On est dans un environnement Win32
- }
- }
- //Exemple d'appel à la fonction Is64BitOS()...
- Is64Bits = Is64BitOS();
- if(Is64Bits > 0)
- {
- ShowMessage("Le programme tourne sur Windows 64 bits.");
- ProgramPath = "\\Program Files (x86)\\";
- }
- else
- if(Is64Bits == 0)
- {
- ShowMessage("Le programme tourne sur Windows 32 bits.");
- ProgramPath = "\\Program Files\\";
- }
- else
- if(Is64Bits == -1)
- {
- ShowMessage("Le programme ne sait pas déterminer son environnement d'exécution en 32 ou 64 bits...\nVeuillez signaler ce problème aux développeurs ;-)");
- ProgramPath = "\\Program Files\\";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement