Microsoft KB Archive/242588

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

Article ID: 242588

Article Last Modified on 11/21/2006

-

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</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q242588

<div class="symptoms_section">

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.

<div class="cause_section">

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

<div class="resolution_section">

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
 * 1) 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
 * 1) 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); }

<div class="status_section">

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

<div class="references_section">