[Interest] debug QtService

BRM bm_witness at yahoo.com
Thu Nov 8 15:40:28 CET 2012

> From: Sergey <sh0375 at gmail.com>

>Hello, all
>I'm developing windows web service using QtService.
>To debug it, I launch program in VS2005 debugger with -e argument.
>It starts in console mode and handles requests.
>How can I emulate stopping the service, so that all code, which is 
>working usually when windows stops the service?
>I want to make web service method, requesing which I would tell service 
>to stop.
>void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
>     QByteArray path=request.getPath();
>#ifdef _DEBUG
>     if (path.startsWith("/stop")) {
>         //QCoreApplication::instance()->exit(); // this leads to error 
>in  HttpConnectionHandler::run() in line: 
>How to emulate stopping the service here, so that program, running with 
>-e argument would stop normally, as it stops when running as windows 
>     }

You'll have to look up the Windows headers you'll need, but you want to use the Debug() Win32 function.
It triggers the Debugger to run.
The best way to use it is to call it early in the life of the service so you can connect the service with VS in a controlled manner, and then set the break point where you want it and continue to run it.


More information about the Interest mailing list