Very basic question, getting win api return value

H

hellrazor

Hi there,

First of all, I'm very much a C++ amateur (i.e., a newb). I'm having to
program a win32 system service for my employer, and I'm almost done with
the task, but I need help with something that appears to be very basic.

I have a function within the cpp file called StopService:

void StopService()
{
SendMessage(hWnd,WM_QUIT,0,0);
runningService = FALSE;
//set the event that is holding ServiceMain
SetEvent(terminateEvent);
}

Within the above function, I send a "WM_QUIT" message to another
application. I would like to monitor when this application has been
terminated. What would be the best way to do this? I was thinking of
trying to call another win-api function on the window and inspecting the
result. Here's where my knowledge of the language fails me.
I had the following code just to test:

void StopService()
{
int retValue;
char strRetValue[100];

SendMessage(hWnd,WM_QUIT,0,0);

retValue = GetWindowLong(hWnd, GWL_ID);
sprintf(strRetValue,"%d",retValue);

MessageBox( NULL, strRetValue, "title", MB_OK );
runningService = FALSE;
//set the event that is holding ServiceMain
SetEvent(terminateEvent);
}

So I'm trying to display the results of the win-api function within the
message box, but I don't think it's working. Everytime the message box is
executed, the messagebox just displays the number zero, "0" (no quotes).
No matter if the hWnd of the window exists or not.

Any pointers?

Thanks,

Jorge
 
V

Victor Bazarov

hellrazor said:
Hi there,

First of all, I'm very much a C++ amateur (i.e., a newb). I'm having to
program a win32 system service [...]

Please do not cross-post this to comp.lang.c++. It's off-topic here.
Thank you.

Victor
 
H

hellrazor

hellrazor said:
Hi there,

First of all, I'm very much a C++ amateur (i.e., a newb). I'm having to
program a win32 system service [...]

Please do not cross-post this to comp.lang.c++. It's off-topic here.
Thank you.

Victor

Seriously? what makes it off-topic? the code is in C++ ?! seemed like a
good place to ask, considering the traffic here. Should I prefix with
MSVC++ as some people have?
 
V

Victor Bazarov

hellrazor said:
@ord-read.news.verio.net:

hellrazor said:
Hi there,

First of all, I'm very much a C++ amateur (i.e., a newb). I'm having to
program a win32 system service [...]

Please do not cross-post this to comp.lang.c++. It's off-topic here.
Thank you.

Victor


Seriously?

Seriously.

what makes it off-topic?

The fact that is has nothing to do with the _language_ and everything
to do with monitoring when an application has been terminated. C++
does not define "application" or "monitoring". Neither does it define
"sending a WM_QUIT message". These are parts of Windows API and not
the _language_. You incorrectly assumed that they were part of the
language.
the code is in C++ ?! seemed like a
good place to ask, considering the traffic here. Should I prefix with
MSVC++ as some people have?

No, simply don't post off-topic. You found a good place for it, the
comp.os.ms-windows.programmer.win32 newsgroup, confine your Win32
questions to that newsgroup.

If you happen to have C++ _language_ questions in the future, do post
them here, and we'll do our best to help you. However, OS-specific
discussions do not belong to comp.lang.c++. They belong to OS-specific
newsgroups.

Thank you.

Victor

P.S. Take a look at the "Welcome" message posted here once a week by
Shiva, and at the FAQ, for more suggestions about where to post your
questions if you are unsure.
 
A

Alf P. Steinbach

* hellrazor:
hellrazor said:
Hi there,

First of all, I'm very much a C++ amateur (i.e., a newb). I'm having to
program a win32 system service [...]

Please do not cross-post this to comp.lang.c++. It's off-topic here.
Thank you.

Victor

Seriously? what makes it off-topic? the code is in C++ ?! seemed like a
good place to ask, considering the traffic here. Should I prefix with
MSVC++ as some people have?

No.

It's off-topic because it does not concern C++ in any way.

Do not ever cross-post between systemWhatever groups and comp.lang.c++,
and as a general rule (because it causes much confusion) do not cross-post
between comp.lang.c and comp.lang.c++ -- thank you.
 
H

hellrazor

(e-mail address removed) (Alf P. Steinbach) wrote in
* hellrazor:
hellrazor wrote:
Hi there,

First of all, I'm very much a C++ amateur (i.e., a newb). I'm
having to program a win32 system service [...]

Please do not cross-post this to comp.lang.c++. It's off-topic
here. Thank you.

Victor

Seriously? what makes it off-topic? the code is in C++ ?! seemed like
a good place to ask, considering the traffic here. Should I prefix
with MSVC++ as some people have?

No.

It's off-topic because it does not concern C++ in any way.

Do not ever cross-post between systemWhatever groups and
comp.lang.c++, and as a general rule (because it causes much
confusion) do not cross-post between comp.lang.c and comp.lang.c++ --
thank you.

wow, touchy bunch in here, peace!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top