Article ID: 242588 - Last Review: November 21, 2006 - Revision: 3.1

BUG: VTS_UI1 and VTS_PUI1 are defined incorrectly in AfxDisp.h in Visual C++

This article was previously published under Q242588
Expand all | Collapse all

SYMPTOMS

When using the string literals defined for VTS_UI1 or VTS_PUI1 in calling COleDispatchDriver::InvokeHelper() or CWnd::InvokeHelper(), you might get strange results. You might notice any of the following symptoms when using the values defined in AfxDisp.h:
  • An ASSERT on line 321 in file Oledisp2.cpp in the COleDispatchDriver::InvokeHelperV function.
  • A message box stating "Bad variable type."
  • An uncaught exception in WindowProc.
  • A first chance exception in Kernel32.dll.

CAUSE

This is because VTS_UI1 and VTS_PUI1 are defined incorrectly in the Afxdisp.h header file.

RESOLUTION

Do not use VTS_UI1 or VTS_PUI1 in any of your code. Instead, define the correct values for each of these using a name you assign. Code like the following can be used:
//Do NOT use VTS_UI1. It has a value of "0x0F" which is incorrect.
//The correct value for VTS_UI1 is 17 or 0x11
#define MY_VTS_UI1 "\x11"

//Do NOT use VTS_PUI1. It has a value of "0x4F" which is incorrect.
//The correct value for VTS_PUI1 is 81 or 0x51
#define MY_VTS_PUI1 "\x51"

void SomeFunction(BYTE byteVal)
{
 static BYTE parms[] = MY_VTS_UI1; // please note that this is not VTS_UI1
 DISPID dispid = 0x60030000;       // notice that this is different!

 COleDispatchDriver d;
 if (d.CreateDispatch("SomeComObject.SomeComObject.1))
    d.InvokeHelper(dispid, DISPATCH_METHOD, VT_EMPTY, NULL, parms, byteVal);
}
				

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

REFERENCES

241862  (http://support.microsoft.com/kb/241862/EN-US/ ) BUG: ClassWizard Omits Methods that Take BYTE or BYTE* as Parameters

APPLIES TO
  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 4.0 Standard Edition
    • Microsoft Visual C++ 4.1 Subscription
    • Microsoft Visual C++ 4.2 Enterprise Edition
    • Microsoft Visual C++ 4.2 Professional Edition
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
Keywords: 
kbtshoot kbbug kbautomation KB242588
 

Article Translations