Very basic question, getting win api return value



 DEVELOP > c-Plus-Plus > Very basic question, getting win api return value

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "hellrazor"
Date: 15 Jul 2004 01:33:15 PM
Object: Very basic question, getting win api return value
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
.

User: "Victor Bazarov"

Title: Re: Very basic question, getting win api return value 15 Jul 2004 01:42:07 PM
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
.
User: "hellrazor"

Title: Re: Very basic question, getting win api return value 15 Jul 2004 01:53:50 PM
Victor Bazarov <v.Abazarov@comAcast.net> wrote in news:3eAJc.2079$Wd.23009
@ord-read.news.verio.net:

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?
.
User: "Alf P. Steinbach"

Title: Re: Very basic question, getting win api return value 15 Jul 2004 02:10:30 PM
* hellrazor:

Victor Bazarov <v.Abazarov@comAcast.net> wrote in news:3eAJc.2079$Wd.23009
@ord-read.news.verio.net:

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.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.
User: "hellrazor"

Title: Re: Very basic question, getting win api return value 15 Jul 2004 02:35:17 PM
(Alf P. Steinbach) wrote in
news:40f6d5f6.70701390@news.individual.net:

* hellrazor:

Victor Bazarov <v.Abazarov@comAcast.net> wrote in
news:3eAJc.2079$Wd.23009 @ord-read.news.verio.net:

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!
.


User: "Victor Bazarov"

Title: Re: Very basic question, getting win api return value 15 Jul 2004 02:09:44 PM
hellrazor wrote:

Victor Bazarov <v.Abazarov@comAcast.net> wrote in news:3eAJc.2079$Wd.23009
@ord-read.news.verio.net:


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?

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.
.




  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER