#define WIN32_LEAN_AND_MEAN #define STRICT #include #include 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; }