Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Automatischer Aufruf von 32- oder 64-Bit-Setup


1 reply to this topic

Toto

Toto
  • Full Members
  • 9 posts

Posted 12 August 2010 - 15:56

Hallo zusammen,

ich habe zwei getrennte Basic-MSI Setups für 32- und 64-Bit-Systeme.
Da der User möglichst nicht mit der Entscheidung "belastet" werden soll, welches Setup zu nehmen ist, wäre ein vorgeschalteter automatischer Auswahlmechanismus wünschenswert, der je nach (VersionNT64) oder (Not VersionNT64) die eine oder andere Setup.exe in verschiedenen Verzeichnissen aufruft.
Einen Dialog braucht es dafür ja nicht.

Wie kann so was am einfachsten / schnellsten realisieren?
Gibt es evtl. schon was fertiges?

Vielen Dank im voraus.

Edited by Toto, 15 August 2010 - 17:30.

Best Regards / Mit freundlichen Grüßen
Andreas Marschall

Toto

Toto
  • Full Members
  • 9 posts

Posted 15 August 2010 - 18:00

Ich habe es wie folgt gelöst:

eigenen Setup Launcher (VC++, Win32-Konsolen-App) namens Setup.exe geschrieben, welcher aus eigener Setup-ini per GetPrivateProfileString() die Pfade\Namen der beiden zu startenden InstallShield-Setup.exe liest und in Abhängigkeit der Bitbreite des OS die passende per CreateProcess() startet.

Die Bitbreite des OS ermittele ich per IsWow64Process() bzw. dem Example dazu aus MSDN:
CODE
#include <windows.h>
#include <stdio.h>

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");
}


Im Kommentar heißt es in MSDN dazu allerdings:
QUOTE
For compatibility with operating systems that do not support this function, call GetProcAddress to detect whether IsWow64Process is implemented in Kernel32.dll. If GetProcAddress succeeds, it is safe to call this function. Otherwise, WOW64 is not present. Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows because the Kernel32.dll in current versions of 32-bit Windows also contains this function.


Tests auf verschiedenen OS haben bisher jedoch stets die korrekte Funktion von IsWow64() gezeigt.

Wie ist eure Meinung dazu?

Edited by Toto, 15 August 2010 - 18:08.

Best Regards / Mit freundlichen Grüßen
Andreas Marschall