mirror of https://github.com/OpenVPN/openvpn-gui
Warn if interative service is not installed or not running
Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/16/head
parent
352e44f03d
commit
5ce1298452
3
main.c
3
main.c
|
@ -178,6 +178,9 @@ int WINAPI _tWinMain (HINSTANCE hThisInstance,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (!IsUserAdmin())
|
||||
CheckIServiceStatus();
|
||||
|
||||
BuildFileList();
|
||||
if (!VerifyAutoConnections()) {
|
||||
exit(1);
|
||||
|
|
|
@ -229,6 +229,8 @@
|
|||
#define IDS_NFO_RESTARTED 1708
|
||||
#define IDS_ERR_ACCESS_SERVICE_PIPE 1709
|
||||
#define IDS_ERR_WRITE_SERVICE_PIPE 1710
|
||||
#define IDS_ERR_NOTSTARTED_ISERVICE 1711
|
||||
#define IDS_ERR_INSTALL_ISERVICE 1712
|
||||
|
||||
/* Registry Related */
|
||||
#define IDS_ERR_GET_WINDOWS_DIR 1801
|
||||
|
|
|
@ -327,6 +327,10 @@ BEGIN
|
|||
IDS_NFO_RESTARTED "OpenVPN Service Restarted."
|
||||
IDS_ERR_ACCESS_SERVICE_PIPE "Access 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 */
|
||||
IDS_ERR_GET_WINDOWS_DIR "Error getting Windows Directory."
|
||||
|
|
34
service.c
34
service.c
|
@ -241,6 +241,40 @@ int MyReStartService()
|
|||
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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue