Error While Executing Following Code RRS feed

  • Question

  • Hai all,

    // Following is the code taken from MSDN

    #include <stdio.h>
    #include <windows.h>
    #include <winable.h>
    #include <winuser.h>
    #include <oleacc.h>
    #include <winver.h>

    void main () {

    // For this example, assume that the g_szName variable
    // is defined as a global LPTSTR variable.

    // Get the current cursor location.

    POINT ptCursor;
    LPTSTR g_szName; // I had declared this one

    // Setup variables for interface pointers and return value.

    IAccessible* pAcc = NULL;
    HRESULT hr;
    VARIANT varChild;
    int cchName; // I had declared this one


    // See if there is an accessible object under the cursor.

    hr = AccessibleObjectFromPoint(ptCursor, &pAcc, &varChild);

    if (hr == S_OK) {

    // Query on the object's name.

    BSTR bstrName = NULL;
    hr = pAcc->get_accName(varChild, &bstrName);

    // If a name was returned without error,
    // convert it from Unicode to an ANSI/multibyte string.

    if (bstrName && hr == S_OK) {

    WideCharToMultiByte(CP_ACP, 0, bstrName,-1, g_szName, cchName, NULL, NULL);


    While executing this code It gives an error message


    C:\Sample_Programs\SampleTest\Sample.c(34) : error C2039: 'get_accName' : is not a member of 'IAccessible'
    c:\program files\microsoft visual studio\vc98\include\oleacc.h(181) : see declaration of 'IAccessible'

    Error executing cl.exe.


    I had used oleacc.lib while compiling

    I am using Windows 2000 Version 5 ( Service Pack 4 )

    Please Help me how to solve this problem
    Thursday, October 6, 2005 6:57 AM


  • I just tried the code you posted with VC 2003 and VC 2005 and I don't seem ro reproduce the error you are getting. It looks like you might be using older VC versions and headers.

      Ayman Shoukry
      VC++ Team
    Thursday, October 6, 2005 6:26 PM