Very basic question, getting win api return value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hellrazor

    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(hWn d,WM_QUIT,0,0);
    runningService = FALSE;
    //set the event that is holding ServiceMain
    SetEvent(termin ateEvent);
    }

    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(hWn d,WM_QUIT,0,0);

    retValue = GetWindowLong(h Wnd, GWL_ID);
    sprintf(strRetV alue,"%d",retVa lue);

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

    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
  • Victor Bazarov

    #2
    Re: Very basic question, getting win api return value

    hellrazor wrote:[color=blue]
    > 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 [...][/color]

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

    Victor

    Comment

    • hellrazor

      #3
      Re: Very basic question, getting win api return value

      Victor Bazarov <v.Abazarov@com Acast.net> wrote in news:3eAJc.2079 $Wd.23009
      @ord-read.news.verio .net:
      [color=blue]
      > hellrazor wrote:[color=green]
      >> 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 [...][/color]
      >
      > Please do not cross-post this to comp.lang.c++. It's off-topic here.
      > Thank you.
      >
      > Victor
      >[/color]

      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?

      Comment

      • Victor Bazarov

        #4
        Re: Very basic question, getting win api return value

        hellrazor wrote:[color=blue]
        > Victor Bazarov <v.Abazarov@com Acast.net> wrote in news:3eAJc.2079 $Wd.23009
        > @ord-read.news.verio .net:
        >
        >[color=green]
        >>hellrazor wrote:
        >>[color=darkred]
        >>>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 [...][/color]
        >>
        >>Please do not cross-post this to comp.lang.c++. It's off-topic here.
        >>Thank you.
        >>
        >>Victor
        >>[/color]
        >
        >
        > Seriously?[/color]

        Seriously.
        [color=blue]
        > what makes it off-topic?[/color]

        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 "applicatio n" 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.
        [color=blue]
        > 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?[/color]

        No, simply don't post off-topic. You found a good place for it, the
        comp.os.ms-windows.program mer.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.

        Comment

        • Alf P. Steinbach

          #5
          Re: Very basic question, getting win api return value

          * hellrazor:[color=blue]
          > Victor Bazarov <v.Abazarov@com Acast.net> wrote in news:3eAJc.2079 $Wd.23009
          > @ord-read.news.verio .net:
          >[color=green]
          > > hellrazor wrote:[color=darkred]
          > >> 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 [...][/color]
          > >
          > > Please do not cross-post this to comp.lang.c++. It's off-topic here.
          > > Thank you.
          > >
          > > Victor
          > >[/color]
          >
          > 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?[/color]

          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?

          Comment

          • hellrazor

            #6
            Re: Very basic question, getting win api return value

            alfps@start.no (Alf P. Steinbach) wrote in
            news:40f6d5f6.7 0701390@news.in dividual.net:
            [color=blue]
            > * hellrazor:[color=green]
            >> Victor Bazarov <v.Abazarov@com Acast.net> wrote in
            >> news:3eAJc.2079 $Wd.23009 @ord-read.news.verio .net:
            >>[color=darkred]
            >> > 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
            >> >[/color]
            >>
            >> 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?[/color]
            >
            > 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.
            >[/color]

            wow, touchy bunch in here, peace!

            Comment

            Working...