How I can obtain type of WDFOBJECT

Hello!
I have method :
WDFOBJECT
CreateMemoryObject()
{
WDFMEMORY memory;

return memory;
}
and then add this wdf object to collection.
How I can in other side (during getting item object from collection) obtain type of wdf object (that is WDFMEMORY) for work with appropriate wdf-methods on this object ?
Thnx!

I don’t understand your question, so I’m going to guess at what you’re asking: You remove your object from the collection, using one of the methods in WDFCOLLECTION. Having done that, you cast the handle generic WDFOBJECT handle returned to you to the specific type of object (WDFMEMORY) that it in fact is.

Or did I not understand your questions correctly?

Peter

Peter, I’m pretty about WDFCOLLECTION of mutlitypes objects (WDFMEMORY, WDFFILEOBJECT , etc.)

Are you asking “how can I tell what type of object it is”? You can’t. You have to know what object type you stored in the collection. In practice, this is not a problem. There are no compelling reasons to store different object types in a single collection.

Tim, I can solve this by WDF_DECLARE_CUSTOM_TYPE ?

OK… so you have multiple object types in the collection.

Still simple.

Attach a context to each object that has a “Type” field at the same offset in every context. Remove the object, retrieve an arbitrary context, check the “Type” field… them cast the object and type to the correct one.

Peter