Windows service works now!

This commit is contained in:
Adam Ierymenko 2014-02-27 16:28:55 -08:00
parent cbeb9c5236
commit 9d05897f7a
7 changed files with 246 additions and 78 deletions

View file

@ -50,16 +50,19 @@ std::string InstallService(PSTR pszServiceName,
PSTR pszPassword)
{
std::string ret;
char szPath[MAX_PATH];
char szPathTmp[MAX_PATH],szPath[MAX_PATH];
SC_HANDLE schSCManager = NULL;
SC_HANDLE schService = NULL;
if (GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath)) == 0)
if (GetModuleFileName(NULL, szPathTmp, ARRAYSIZE(szPath)) == 0)
{
ret = "GetModuleFileName failed, unable to get path to self";
goto Cleanup;
}
// Quote path in case it contains spaces
_snprintf_s(szPath,sizeof(szPath),"\"%s\"",szPathTmp);
// Open the local default service control manager database
schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT |
SC_MANAGER_CREATE_SERVICE);