How to stop a vb6 appl from a C# service

  • Thread starter Thread starter José Joye
  • Start date Start date
J

José Joye

Hi,

For some reason, I have a VB6 appl (that expose no forms) that I mustcontrol
using a C# service.
I'm able to start it from my service using the Process class.
However, I do not really understand how to properly stop it.
I thought the normal way was to get send the WM_QUIT to the created process:
eg:
IntPtr WindowHandle = m_Process.MainWindowHandle;
int nCompletionCode = -1;
if (!SendMessageTimeout( WindowHandle,
WM_QUIT,0,null,
SMTO_BLOCK + SMTO_ABORTIFHUNG +
SMTO_NOTIMEOUTIFNOTHUNG,
15000, out nCompletionCode))

However, the main window handle is 0!

Is there another way for a VB6 application started from a Service to be
PROPERLY stopped (I mean not killed)?


Thanks a lot!
José
 
Ok,
I found it.

It is necessary to set the "allow service to interact with desktop" so as to
get the handle of the main window.

José
 
Back
Top