Warn if interative service is not installed or not running

Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/16/head
Selva Nair 2016-02-16 15:49:13 -05:00
parent 352e44f03d
commit 5ce1298452
4 changed files with 43 additions and 0 deletions

3
main.c
View File

@ -178,6 +178,9 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
exit(1); exit(1);
} }
if (!IsUserAdmin())
CheckIServiceStatus();
BuildFileList(); BuildFileList();
if (!VerifyAutoConnections()) { if (!VerifyAutoConnections()) {
exit(1); exit(1);

View File

@ -229,6 +229,8 @@
#define IDS_NFO_RESTARTED 1708 #define IDS_NFO_RESTARTED 1708
#define IDS_ERR_ACCESS_SERVICE_PIPE 1709 #define IDS_ERR_ACCESS_SERVICE_PIPE 1709
#define IDS_ERR_WRITE_SERVICE_PIPE 1710 #define IDS_ERR_WRITE_SERVICE_PIPE 1710
#define IDS_ERR_NOTSTARTED_ISERVICE 1711
#define IDS_ERR_INSTALL_ISERVICE 1712
/* Registry Related */ /* Registry Related */
#define IDS_ERR_GET_WINDOWS_DIR 1801 #define IDS_ERR_GET_WINDOWS_DIR 1801

View File

@ -327,6 +327,10 @@ BEGIN
IDS_NFO_RESTARTED "OpenVPN Service Restarted." IDS_NFO_RESTARTED "OpenVPN Service Restarted."
IDS_ERR_ACCESS_SERVICE_PIPE "Access to service pipe failed." IDS_ERR_ACCESS_SERVICE_PIPE "Access to service pipe failed."
IDS_ERR_WRITE_SERVICE_PIPE "Writing to service pipe failed." IDS_ERR_WRITE_SERVICE_PIPE "Writing to service pipe failed."
IDS_ERR_INSTALL_ISERVICE """OpenVPNServiceInteractive"" is not installed.\n"
"Tasks requiring administrative access may not work."
IDS_ERR_NOTSTARTED_ISERVICE """OpenVPNServiceInteractive"" is not started.\n"
"Tasks requiring administrative access may not work."
/* registry */ /* registry */
IDS_ERR_GET_WINDOWS_DIR "Error getting Windows Directory." IDS_ERR_GET_WINDOWS_DIR "Error getting Windows Directory."

View File

@ -241,6 +241,40 @@ int MyReStartService()
return(false); return(false);
} }
bool
CheckIServiceStatus()
{
SC_HANDLE schSCManager;
SC_HANDLE schService;
SERVICE_STATUS ssStatus;
// Open a handle to the SC Manager database.
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (NULL == schSCManager)
return(false);
schService = OpenService(schSCManager, _T("OpenVPNServiceInteractive"),
SERVICE_QUERY_STATUS);
if (schService == NULL &&
GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST)
{
/* warn that iservice is not installed */
ShowLocalizedMsg(IDS_ERR_INSTALL_ISERVICE);
return(false);
}
if (!QueryServiceStatus(schService, &ssStatus))
return(false);
if (ssStatus.dwCurrentState != SERVICE_RUNNING)
{
/* warn that iservice is not started */
ShowLocalizedMsg(IDS_ERR_NOTSTARTED_ISERVICE);
return(false);
}
return true;
}
int CheckServiceStatus() int CheckServiceStatus()
{ {