David L Hill
May 20th, 1999, 12:10 PM
I want to pass either an IStorage* or an IStream* parameter to a method. I am planning on passing it as a long and then casting it back as an IStorage* or IStream*.
I have several concerns. The first is I am not sure if I am going to have reference count problems.
Another is how to determine if it is an IStorage* or IStream* since I would prefer to use the same method with only the one parameter. I was planning on using code like the following:
IStorage* p1;
IStream* p2;
p1 = CComQIPtr<IStorage>((IUnknown*)lPointer);
p2 = CComQIPtr<IStream>((IUnknown*)lPointer);
if (p1 != NULL)
{
....
}
else if (p2 != NULL)
{
....
}
I have not seen any problems so far. Does anybody have any suggestions on the soundness of this design or any potential problems? Are there better methods of accomplishing this?
Thank you for any assistance that you are able to provide.
I have several concerns. The first is I am not sure if I am going to have reference count problems.
Another is how to determine if it is an IStorage* or IStream* since I would prefer to use the same method with only the one parameter. I was planning on using code like the following:
IStorage* p1;
IStream* p2;
p1 = CComQIPtr<IStorage>((IUnknown*)lPointer);
p2 = CComQIPtr<IStream>((IUnknown*)lPointer);
if (p1 != NULL)
{
....
}
else if (p2 != NULL)
{
....
}
I have not seen any problems so far. Does anybody have any suggestions on the soundness of this design or any potential problems? Are there better methods of accomplishing this?
Thank you for any assistance that you are able to provide.