Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

WaitForSingleObject()

Options
  • 04-03-2007 7:14pm
    #1
    Closed Accounts Posts: 2,349 ✭✭✭


    Hola,

    Can anyone tell me if RegisterWaitForSingleObject() is the callback equivalent of WaitForSingleObject().

    Basically I need to be able to get on with my program while checking the status of a handle created by CreateProcess() so that when the process closes I can do certain things.
    HANDLE *test = NULL;
    RegisterWaitForSingleObject(test,cmdhandle, cmd.DestroyCmd(),	0, INFINITE, WT_EXECUTEONLYONCE);
    

    And the callback function:
    WAITORTIMERCALLBACK CALLBACK rcmd::DestroyCmd()
    {
    	closesocket(conn);
    	return 0;
    }
    

    That's my best guess about what to do so far. It crashes, something about the "0" in the RegisterWaitForSingleObject call I think?


Comments

  • Registered Users Posts: 2,150 ✭✭✭dazberry


    That seems pretty nifty alright. Using your sample I've managed to get a version working in Delphi (RegisterWaitForSingleObject isn't included for some reason so I had to include it manually).

    Anyway my C/C++ is really rusty... but my guess is that here...
    HANDLE *test = NULL;

    To me this would appear to be creating a pointer to a handle and initalising the pointer to null. Instead you need to be passing a non null pointer to the handle (even if the actual HANDLE "value" is undefined or INVALID_HANDLE_VALUE) if that makes sense?

    D.


  • Closed Accounts Posts: 2,349 ✭✭✭nobodythere


    You have to stick "#define _WIN32_WINNT 0x0500" at the top of your header file (or Delphi equivalent) for it to work because RegisterWaitForSingleObject() is XP only afaik.

    I didn't cop the HANDLE *test thing at all for whatever reason. Thanks, I'll try some more and get back to you.

    Otherwise I'll have to learn to use threads :/


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    according to msdn, the prototype for the callback is

    [PHP]VOID CALLBACK WaitOrTimerCallback(
    PVOID lpParameter,
    BOOLEAN TimerOrWaitFired
    );[/PHP]

    does not return anything, and passes 2 arguements, which should be removed from the stack before returning to callee, your prototype does not accept any arguements???

    just a guess for why it crashes..


Advertisement