|
-
January 28th, 2012, 12:09 AM
#4
Re: Service error 1053 windows 7
Sure. The problem part is main().
Code:
int _tmain( int argc, TCHAR* argv[] )
{
int choice = 0;
std::cout <<"Type a choice";
std::cin >> choice;
switch(choice)
{
While it's okay to do this in user mode, service mode must not do that waiting on input. The thing is that service starts in isolated session user just has no chance to input to. So, service must start based either on no question, or on a command line argument.
Here's your main() fixed. Your service runs just fine with it.
Code:
int _tmain( int argc, TCHAR* argv[] )
{
int choice = 2;
if (argc > 1)
{
choice = _ttoi(argv[1]);
}
switch(choice)
{
case 0:
InstallService();
break;
case 1:
UninstallService();
break;
case 2:
RunService();
break;
}
return 0;
}
BTW, as you can see, the issue has nothing to do with Windows 7. Your original service is not able to run in any Windows.
Last edited by Igor Vartanov; January 28th, 2012 at 01:02 AM.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|