views:

102

answers:

1

Looking for an example of how to read the last semaphore count from ReleaseSemaphore
Having problems creating a basic local variable to store LPLONG lpPreviousCount into and print out. Looks like I need a pointer to the variable but not having much luck.

If you can point me in the right direction, that would be greatly appreciated.

Thanks.

+2  A: 

Create a LONG variable and pass a pointer to it:

LONG previousCount;
BOOL success = ReleaseSemaphore(hSemaphore, releaseCount, &previousCount);
if (success) {
    //do something with previousCount
}

This works because LPLONG is a pointer to LONG. You must create the LONG variable as a place for ReleaseSemaphore to store the value.

interjay
doesn't seem to like that. Get a compile error passing by reference.
Tommy
This code should work. Please post your exact code and the error message.
interjay
Yes this does work. Thanks!
Tommy