Using Windows message as a Handle
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Using Windows message as a Handle

  1. #1
    Join Date
    Sep 2009
    Posts
    4

    Smile Using Windows message as a Handle

    Hi,

    I am writing one of my first multithreaded programs.

    In one of the thread, I am using WaitForSingleObject method to detect the USER LOG-OFF on a system.

    May I know, that is there any way to convert Windows Messages to Handles.

    Or is there any other better way to make that particular Thread run when a system event happens like user log-off.

    Thanks in advance.

  2. #2
    Join Date
    Sep 2009
    Posts
    4

    Smile Re: Using Windows message as a Handle

    May be I was not clear. I think I havent given the correct information/ I did not put it in right words. I am sorry for that.

    Currently, I have a MultiThreaded program which runs perfectly with the "time-out interval" in "WaitForSingleObject" function. I want to make it "INFINITE" and make it do some work for me when it detects "user Log-off" event from windows.

    For now I just know that, "WaitForSingleObject" function only takes handle and time out.
    Is there a way to send the windows event as Handle to this function?
    If, I am not going on a right path can someone please please suggest me, what I can do to improve this code and make the program RUN.

    Thanks in Advance.

  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Using Windows message as a Handle

    So how are you detecting the user log-off event? Does your program have a message pump? What is your WaitForSingleObject() function using as a handle?

  4. #4
    Join Date
    Jan 2010
    Posts
    12

    Re: Using Windows message as a Handle

    well.... I'd have my main process thread (which is a UI thread with a message pump) create a new handle (global) at startup, then hook the log-off event, when the log-off occurs, set your global handle and your thread will run.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center