473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to stop a vb6 appl from a C# service

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é
Nov 15 '05 #1
1 1422
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é

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:uQ**************@tk2msftngp13.phx.gbl...
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é

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pola | last post by:
Please Help I am using VC++ in win 2000 In my appl (Win32 project) I want to control the close operation of the apl (for example if somebody will try to close appl from the "Windows Task Manager")...
1
by: Peter Steele | last post by:
Okay, I assume I'm missing something obvious here. I have created a simple service in C# that on starting spawns a thread to do some processing. The service can be stopped with a "net stop" command...
2
by: Prasad | last post by:
Hi, I am writing a service which takes a long time to stop after the OnStop call is given by the Services Snap-in. The problem is I cannot cut down on the time that it takes to Stop. The Service...
6
by: Jacobus Terhorst | last post by:
Using C#: I tried: ServiceController me = new ServiceController(this.ServiceName); me.Stop(); it raises an exception: Cannot find Service I also tried:
6
by: Alpha | last post by:
Hi, I'm fixing a bug in an application and need to step thru the appl to find where it's occuring. The main project includs 33 other projects each having a .resx file in it. When I step through it...
7
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
7
by: dotnetprogrammer via DotNetMonster.com | last post by:
I have an NT Service written in c# (.net framwork 2.0). When it hits a certain error condition, I want it to be to cause itself to stop. How can I do this? -- Message posted via...
7
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
0
by: mattcfisher | last post by:
Hi, I have two windows services running together. One is the main program, and one is an "updater" wrapper for the main. The updater service starts and stops the main one (as in you should never...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.