Microsoft KB Archive/147741

{|
 * width="100%"|

How to Upgrade the 16-bit SDISP Example from Microsoft Excel

 * }

5.00   | 5.00 WINDOWS | WINDOWS NT kbprg

-

The information in this article applies to:


 * Microsoft Excel Software Development Kit, version 5.0

-

The simplest example of a Microsoft Excel OLE Automation Controller is a DLL function that takes an object as an argument, obtains a DISPID for the object's Value property, and then uses PropertyPut or PropertyGet to set or get the value of the object.

The Microsoft Excel Software Development Kit version 5.0 contains SDISP, a 16-bit sample DLL, that demonstrates a simple OLE Automation Controller. To update the SDISP sample to 32-bits for use with Microsoft Excel 7.0, the source code in SDISP.C needs to be modified in the following ways.

  The include files should be:   #include    #include    #include    #include    #include    The function prototype for CalcCells should be changed to:   SCODE __declspec(dllexport) CalcCells(LPDISPATCH FAR *ppdsSourceRange,                                         VARIANTARG FAR *pvtResult)   32-bit OLE strings need to be UNICODE. The Data Type for the variable lpszName in the CalcCells function should be changed to:   LPOLESTR lpszName = L"Value";   The variable lpszName is used twice in CalcCells in GetIDsOfNames. It is typecast to (char FAR* FAR*)&lpszName. The typecasting should be removed. The line would read: <pre class="CODESAMP">  hr = (*((*ppdsSourceRange)->lpVtbl->GetIDsOfNames)) (*ppdsSourceRange, &IID_NULL, &lpszName,        1, LOCALE_SYSTEM_DEFAULT, &dispidValue); </li></ol>

Additional query words: 5.00

Keywords :

Version : :5.0

Platform : NT WINDOWS

Issue type :

Technology :