How to get event name from descriptor

I have an array of Win32 event handlers that I am expecting from using WaitForMultipleObjects (). This returns the index in the array of events that were raised, but what I need to know is the name of the event. I've been looking through MSDN and can't see anything for this.

Basically I have a class that monitors the registry through events using RegNotifyChangeKeyValue () for a period of time, but before it starts other classes, register interest in keys and values. Then I wait for a separate thread and report back the name of the keys that have changed. The name of the event is the key the event is for and I don't know until it is shown how many of them will be or what they will trigger. I don't want to create one thread for each key as it is not very efficient.

Does anyone know how to get the event name or a better way to do this?

+2


source to share


3 answers


Personally, I wouldn't do that. Create your own mapping (std :: map?) Between the event name and the key, and then do your own search for when the event is signaled.



0


source


Maybe you can do it with undocumented NT stuff, maybe NtQueryObject(handle,ObjectNameInformation,....)



+1


source


Typically the event name is used to call OpenEvent () to get the Handle. This way, you don't have to bind the handle at runtime, but instead settle for a naming convention for the event name.

I can think of three ways to do this:

  • Loop through all hardcoded event names and call OpenEvent ()
  • Store descriptors and names to std :: map
  • Create a class to store your descriptors and names (probably on std :: map) and write methods to quickly get the name from the descriptor.

Do you determine what action to take based on the event name? An if if if if statement that checks the handle names one by one to determine what action to take? This scenario usually leads me to inheritance as a potential solution. Bear with me a little.

What if you are creating a base class, say EventAction. This has an event handle and a go_go_commandos () virtual member function. You exit it for each "event" that has an action to take, and implement the action in the go_go_commandos () method for each receiver class.

Now you need a container, so you can say actionlist-> GetEventAction (handle) -> go_go_commandos ().

Did it help at all?

0


source







All Articles