473,395 Members | 1,468 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,395 software developers and data experts.

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
Jul 22 '05 #1
5 1466
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
Jul 22 '05 #2
Victor Bazarov <v.********@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?
Jul 22 '05 #3
hellrazor wrote:
Victor Bazarov <v.********@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.
Jul 22 '05 #4
* hellrazor:
Victor Bazarov <v.********@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?
Jul 22 '05 #5
al***@start.no (Alf P. Steinbach) wrote in
news:40***************@news.individual.net:
* hellrazor:
Victor Bazarov <v.********@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!
Jul 22 '05 #6

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

Similar topics

4
by: user | last post by:
Is there a way, from within a getter/setter method linked to a propert, that I can tell which property triggered the method? This would be great, because I need a great number of these...
6
by: Paul Fitzpatrick | last post by:
Hi, This is a real beginner question! I have a form with a few types of products. I need to limit the number that the user puts in for quantity of each product - I have to keep it below 2. ...
3
by: Chris Mantoulidis | last post by:
I never liked pointers really much, so I decided to stay away from them for a while. I know they're useful, so now I decided to actually learn how the work, use them, etc. Here's my question......
10
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long...
5
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the...
8
by: =?Utf-8?B?TFc=?= | last post by:
Hello! I am just learning about forms authentication so please excuse this basic question. I am using .NET 1.1 and C#. I have created my web.config file and my login.aspx and the associated cs...
10
by: mcl | last post by:
Why can I not the change the value of a variable in another class, when I have passed it via a parameter list. I am sure I am being stupid, but I thought passed objects were Read/ Write eg...
1
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from...
56
by: mdh | last post by:
As I begin to write more little programs without the help of the exercises, little things pop up that I need to understand more fully. Thus, below, and although this is not the exact code, the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.