I have a c++ project in visual studio 2008 on windows 7 where I try to start a new service. I'm running visual studio as administrator. I cant start the service (serviceMain is not even called).
this is my main function:
wchar_t str[] = {'s','e','s','m'};
int _tmain(int argc, _TCHAR* argv[])
{
SERVICE_TABLE_ENTRY dispTable[] =
{
{(wchar_t*)str, ServiceWork::ServiceMain},
{NULL, NULL}
};
int i = StartServiceCtrlDispatcher(dispTable);
int j = GetLastError();
return 0;
}
the output is:
. . .
'SessionMonitor.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll'
'SessionMonitor.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll'
'SessionMonitor.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll'
First-chance exception at 0x7638b9bc in SessionMonitor.exe: 0x00000005: Access is denied. The thread 'Win32 Thread' (0x129c) has exited with code 0 (0x0). The program '[2492] SessionMonitor.exe: Native' has exited with code 0 (0x0).
on debug, j is 1063 - ERROR_FAILED_SERVICE_CONTROLLER_CONNECT
does anyone encountered this problem before? any solution?
thank you, Liron