- winsetup: Change the delete file after reboot code to use

MoveFileEx instead of the RunOnce registry key.  It does what
        I was originally trying to do directly to:
        HKLM\SYSTEM\CurrentControlSet\Control\
        Session Manager\PendingFileRenameOperations
        But I ran into issues across various versions of Windows.
        
        Thanks to Nicolas Alvarez for pointing out the API.
    - scrsave: Some more screensaver clean-up.
    - lib: Fix an infinate loop problem in get_exit_status,
        luckly BOINC wasn't using it.
        
    clientscr/
        screensaver.cpp
    lib/
        util.C
    win_build/installerv2/redist/Windows/src/boinccas/
        CAValidateRebootRequest.cpp

svn path=/trunk/boinc/; revision=15945
This commit is contained in:
Rom Walton 2008-08-29 19:06:04 +00:00
parent ca00559575
commit 90d1109bfe
4 changed files with 33 additions and 56 deletions

View File

@ -7090,3 +7090,23 @@ David 28 Aug 2008
client/
app_start.C
Rom 29 Aug 2008
- winsetup: Change the delete file after reboot code to use
MoveFileEx instead of the RunOnce registry key. It does what
I was originally trying to do directly to:
HKLM\SYSTEM\CurrentControlSet\Control\
Session Manager\PendingFileRenameOperations
But I ran into issues across various versions of Windows.
Thanks to Nicolas Alvarez for pointing out the API.
- scrsave: Some more screensaver clean-up.
- lib: Fix an infinate loop problem in get_exit_status,
luckly BOINC wasn't using it.
clientscr/
screensaver.cpp
lib/
util.C
win_build/installerv2/redist/Windows/src/boinccas/
CAValidateRebootRequest.cpp

View File

@ -327,12 +327,12 @@ void *CScreensaver::DataManagementProc() {
while (true) {
for (int i = 0; i < 4; i++) {
// ***
// *** Things that should be run frequently.
// *** 4 times per second.
// ***
// ***
// *** Things that should be run frequently.
// *** 4 times per second.
// ***
// Are we supposed to exit the screensaver?
// Are we supposed to exit the screensaver?
if (m_QuitDataManagementProc) { // If main thread has requested we exit
if (m_hGraphicsApplication || graphics_app_result_ptr) {
terminate_screensaver(m_hGraphicsApplication, graphics_app_result_ptr);
@ -514,27 +514,18 @@ void *CScreensaver::DataManagementProc() {
// Is the graphics app still running?
if (m_hGraphicsApplication) {
#ifdef _WIN32
DWORD dwStatus = STILL_ACTIVE;
BOOL bRetVal = FALSE;
bRetVal = GetExitCodeProcess(m_hGraphicsApplication, &dwStatus);
BOINCTRACE(_T("CScreensaver::DataManagementProc - GetExitCodeProcess RetVal = '%d', Status = '%d'\n"), bRetVal, dwStatus);
if (bRetVal && (dwStatus != STILL_ACTIVE)) {
if (!process_exists(m_hGraphicsApplication)) {
// Something has happened to the previously selected screensaver
// application. Start a different one.
BOINCTRACE(_T("CScreensaver::DataManagementProc - Graphics application isn't running, start a new one.\n"));
m_hGraphicsApplication = 0;
graphics_app_result_ptr = NULL;
continue;
} else {
#ifdef _WIN32
CheckForegroundWindow();
}
#else
if (waitpid(m_hGraphicsApplication, 0, WNOHANG) == m_hGraphicsApplication) {
m_hGraphicsApplication = 0;
graphics_app_result_ptr = NULL;
continue;
}
#endif
}
}
}
#endif // ! SIMULATE_NO_GRAPHICS

View File

@ -440,6 +440,8 @@ int get_exit_status(HANDLE pid_handle) {
if (GetExitCodeProcess(pid_handle, &status)) {
if (status == STILL_ACTIVE) {
boinc_sleep(1);
} else {
break;
}
}
}

View File

@ -70,9 +70,6 @@ UINT CAValidateRebootRequest::OnExecution()
uiReturnValue = GetProperty( _T("INSTALLDIR"), strInstallDirectory );
if ( uiReturnValue ) return uiReturnValue;
uiReturnValue = GetProperty( _T("RETURN_REBOOTREQUESTED"), strRebootRequested );
if ( uiReturnValue ) return uiReturnValue;
// Create reboot pending file
//
@ -82,43 +79,10 @@ UINT CAValidateRebootRequest::OnExecution()
if (fRebootPending) fclose(fRebootPending);
// Create a registry key to delete the RebootInProgress.txt flag
// file on a reboot.
// Schedule the file for deletion after a reboot.
//
if ( _T("1") == strRebootRequested )
{
LONG lReturnValue;
HKEY hkSetupHive;
MoveFileEx(strRebootPendingFilename.c_str(), NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
lReturnValue = RegCreateKeyEx(
HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce"),
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_READ | KEY_WRITE,
NULL,
&hkSetupHive,
NULL
);
if (lReturnValue == ERROR_SUCCESS)
{
tstring strCommand;
strCommand = _T("cmd.exe /c \"del \"") + strRebootPendingFilename + _T("\"\"");
RegSetValueEx(
hkSetupHive,
_T("*BOINCRebootPendingCleanup"),
0,
REG_SZ,
(CONST BYTE *)strCommand.c_str(),
(DWORD)(strCommand.size()*sizeof(TCHAR))
);
RegCloseKey(hkSetupHive);
}
}
return ERROR_SUCCESS;
}