PRB: CDO (1.x) Session GetDefaultFolder Method Fails with VARIANT (179233)
The information in this article applies to:
- Collaboration Data Objects (CDO) 1.2
- Collaboration Data Objects (CDO) 1.21
This article was previously published under Q179233 SYMPTOMS
When writing a C++ program that uses the Collaboration Data Objects (CDO)
library, the reference to a pointer to a folder declared as a VARIANT data
type causes a system error in the program. The error that occurs is:
Unhandled Exception: Privileged Instruction.
CAUSE
The GetDefaultFolder method returns a value of type variant_t on the stack.
This is copied to the VARIANT variable. The default constructor of the
VARIANT does not increment the reference counter for the dispval member so
that when the temporary variant_t is destroyed, dispatch member of the
VARIANT is no longer valid.
RESOLUTION
Declare the variable that holds the result of the GetDefaultFolder method
as variant_t rather than VARIANT. The constructor of the variant_t
increments the reference counter for the resulting folder pointer, so that
the dispatch member remains valid.
For example, in the code sample below, the variable vtFolder should be
declared as type variant_t not as type VARIANT.
Modification Type: | Minor | Last Reviewed: | 3/4/2004 |
---|
Keywords: | kbcode kberrmsg kbMsg kbprb KB179233 |
---|
|