ad309be592
git-svn-id: svn://10.65.10.50/branches/R_10_00@22692 c028cbd2-c16b-5b4b-a496-9718f37d4682
49 lines
1.3 KiB
C++
Executable File
49 lines
1.3 KiB
C++
Executable File
#define WIN32_LEAN_AND_MEAN
|
|
#define STRICT
|
|
#include <windows.h>
|
|
#include <shellapi.h>
|
|
|
|
BOOL ErrorBox(LPCTSTR msg)
|
|
{
|
|
::MessageBox(NULL, msg, TEXT("Setup"), MB_OK | MB_ICONERROR);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL FileExists(LPCTSTR name)
|
|
{
|
|
return ::GetFileAttributes(name) != 0xFFFFFFFF;
|
|
}
|
|
|
|
BOOL IsVistaOrLater()
|
|
{
|
|
BOOL good = FALSE;
|
|
OSVERSIONINFOEX osinfo; ZeroMemory(&osinfo, sizeof(osinfo));
|
|
osinfo.dwOSVersionInfoSize = sizeof(osinfo);
|
|
if (::GetVersionEx((OSVERSIONINFO*)&osinfo))
|
|
good = osinfo.dwMajorVersion >= 6;
|
|
return good;
|
|
}
|
|
|
|
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hinstPrev, LPSTR pCmdLine, int nCmdShow)
|
|
{
|
|
BOOL bFound = FileExists(TEXT("SetCmpUp.exe"));
|
|
if (!bFound)
|
|
{
|
|
::SetCurrentDirectory(TEXT("program\\setup"));
|
|
bFound = FileExists(TEXT("SetCmpUp.exe"));
|
|
if (!bFound)
|
|
ErrorBox(TEXT("Impossibile trovare SetCmpUp.exe"));
|
|
}
|
|
if (bFound)
|
|
{
|
|
if (IsVistaOrLater())
|
|
bFound = (int)::ShellExecute(NULL, TEXT("runas"), TEXT("SetCmpUp.exe"), NULL, NULL, SW_SHOWMAXIMIZED) > 32;
|
|
else
|
|
bFound = ::WinExec("SetCmpUp.exe", SW_SHOWMAXIMIZED) > 32;
|
|
if (!bFound)
|
|
ErrorBox(TEXT("Impossibile eseguire SetCmpUp.exe"));
|
|
}
|
|
|
|
return bFound ? 0 : 2;
|
|
}
|