Opening Windows Update
Posted: Fri May 07, 2010 2:25 am
If any of you want to add that little extra bit of credibility to your programs (maybe you have it named as WindowsUpdate.exe), the following code will open Windows Update. You'll need to include windows.h as normal.
Code: Select all
void openWindowsUpdate() {
OSVERSIONINFOEX os;
memset(&os, 0, sizeof(OSVERSIONINFOEX));
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx((LPOSVERSIONINFOW) &os);
int id = getOSVersionID(os);
// Windows XP
if (os.dwMajorVersion < 6) {
ShellExecuteW(0, L"open", L"control.exe", L"wuaucpl.cpl", 0, SW_SHOW);
}
// Windows Vista or 7
else {
ShellExecuteW(0, L"open", L"wuapp.exe", NULL, 0, SW_SHOW);
}
}