mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:52:57 +00:00
- Improve start / stop control
- Use GetSelectedService exclusively svn path=/trunk/; revision=20995
This commit is contained in:
parent
56499760a8
commit
088390e90c
3 changed files with 63 additions and 15 deletions
|
@ -23,6 +23,7 @@ BOOL Control(HWND hProgDlg, DWORD Control)
|
|||
LVITEM item;
|
||||
DWORD BytesNeeded = 0;
|
||||
DWORD Loop = 5; //FIXME: testing value. needs better control
|
||||
DWORD dwStartTickCount, dwOldCheckPoint;
|
||||
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = GetSelectedItem();
|
||||
|
@ -72,15 +73,28 @@ BOOL Control(HWND hProgDlg, DWORD Control)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Save the tick count and initial checkpoint. */
|
||||
dwStartTickCount = GetTickCount();
|
||||
dwOldCheckPoint = ServiceStatus.dwCheckPoint;
|
||||
|
||||
/* loop whilst service is not running */
|
||||
/* FIXME: needs more control adding. 'Loop' is temparary */
|
||||
while (ServiceStatus.dwCurrentState != Control || !Loop)
|
||||
{
|
||||
DWORD dwWaitTime;
|
||||
|
||||
dwWaitTime = ServiceStatus.dwWaitHint / 10;
|
||||
|
||||
if( dwWaitTime < 500 )
|
||||
dwWaitTime = 500;
|
||||
else if ( dwWaitTime > 5000 )
|
||||
dwWaitTime = 5000;
|
||||
|
||||
/* increment the progress bar */
|
||||
SendMessage(hProgBar, PBM_STEPIT, 0, 0);
|
||||
|
||||
/* wait before checking status */
|
||||
Sleep(ServiceStatus.dwWaitHint / 8);
|
||||
Sleep(dwWaitTime);
|
||||
|
||||
/* check status again */
|
||||
if (! QueryServiceStatusEx(
|
||||
|
@ -93,7 +107,22 @@ BOOL Control(HWND hProgDlg, DWORD Control)
|
|||
GetError(0);
|
||||
return FALSE;
|
||||
}
|
||||
Loop--;
|
||||
|
||||
if (ServiceStatus.dwCheckPoint > dwOldCheckPoint)
|
||||
{
|
||||
/* The service is making progress. increment the progress bar */
|
||||
SendMessage(hProgBar, PBM_STEPIT, 0, 0);
|
||||
dwStartTickCount = GetTickCount();
|
||||
dwOldCheckPoint = ServiceStatus.dwCheckPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GetTickCount() - dwStartTickCount > ServiceStatus.dwWaitHint)
|
||||
{
|
||||
/* No progress made within the wait hint */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseServiceHandle(hSc);
|
||||
|
|
|
@ -96,15 +96,10 @@ BOOL GetExecutablePath(LPTSTR *ExePath)
|
|||
SC_HANDLE hSc = NULL;
|
||||
LPQUERY_SERVICE_CONFIG pServiceConfig = NULL;
|
||||
ENUM_SERVICE_STATUS_PROCESS *Service = NULL;
|
||||
LVITEM item;
|
||||
DWORD BytesNeeded = 0;
|
||||
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = GetSelectedItem();
|
||||
SendMessage(hListView, LVM_GETITEM, 0, (LPARAM)&item);
|
||||
|
||||
/* copy pointer to selected service */
|
||||
Service = (ENUM_SERVICE_STATUS_PROCESS *)item.lParam;
|
||||
Service = GetSelectedService();
|
||||
|
||||
/* open handle to the SCM */
|
||||
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE);
|
||||
|
|
|
@ -19,17 +19,13 @@ BOOL DoStartService(HWND hProgDlg)
|
|||
SC_HANDLE hSc;
|
||||
SERVICE_STATUS_PROCESS ServiceStatus;
|
||||
ENUM_SERVICE_STATUS_PROCESS *Service = NULL;
|
||||
LVITEM item;
|
||||
DWORD BytesNeeded = 0;
|
||||
INT ArgCount = 0;
|
||||
DWORD Loop = 5; //FIXME: testing value. needs better control
|
||||
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = GetSelectedItem();
|
||||
SendMessage(hListView, LVM_GETITEM, 0, (LPARAM)&item);
|
||||
DWORD dwStartTickCount, dwOldCheckPoint;
|
||||
|
||||
/* copy pointer to selected service */
|
||||
Service = (ENUM_SERVICE_STATUS_PROCESS *)item.lParam;
|
||||
Service = GetSelectedService();
|
||||
|
||||
/* set the progress bar range and step */
|
||||
hProgBar = GetDlgItem(hProgDlg, IDC_SERVCON_PROGRESS);
|
||||
|
@ -70,10 +66,23 @@ BOOL DoStartService(HWND hProgDlg)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Save the tick count and initial checkpoint. */
|
||||
dwStartTickCount = GetTickCount();
|
||||
dwOldCheckPoint = ServiceStatus.dwCheckPoint;
|
||||
|
||||
/* loop whilst service is not running */
|
||||
/* FIXME: needs more control adding. 'Loop' is temparary */
|
||||
while (ServiceStatus.dwCurrentState != SERVICE_RUNNING || !Loop)
|
||||
{
|
||||
DWORD dwWaitTime;
|
||||
|
||||
dwWaitTime = ServiceStatus.dwWaitHint / 10;
|
||||
|
||||
if( dwWaitTime < 500 )
|
||||
dwWaitTime = 500;
|
||||
else if ( dwWaitTime > 5000 )
|
||||
dwWaitTime = 5000;
|
||||
|
||||
/* increment the progress bar */
|
||||
SendMessage(hProgBar, PBM_STEPIT, 0, 0);
|
||||
|
||||
|
@ -91,7 +100,22 @@ BOOL DoStartService(HWND hProgDlg)
|
|||
GetError(0);
|
||||
return FALSE;
|
||||
}
|
||||
Loop--;
|
||||
|
||||
if (ServiceStatus.dwCheckPoint > dwOldCheckPoint)
|
||||
{
|
||||
/* The service is making progress. increment the progress bar */
|
||||
SendMessage(hProgBar, PBM_STEPIT, 0, 0);
|
||||
dwStartTickCount = GetTickCount();
|
||||
dwOldCheckPoint = ServiceStatus.dwCheckPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(GetTickCount() - dwStartTickCount > ServiceStatus.dwWaitHint)
|
||||
{
|
||||
/* No progress made within the wait hint */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseServiceHandle(hSc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue