Pointers in ASP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MeAndI

    #1

    Pointers in ASP

    Hi to all,

    I've integrate a custom ActiveX (builded in C++) in my ASP pages, but now I
    have a question/problem.
    I have a function which uses the pointers as parameters.
    When I call this function in my ASP page I have this error (Data type
    missmatch..)
    e.g.
    dim param1
    dim param2
    param1 = ""
    param2 = ""
    retval = myActiveX.myFun ction (param1, param2)

    myFunction is declared as follow:
    long CmyActiveXCtrl: :myFunction(BST R FAR* param1, BSTR FAR* param2)

    It is possible to call this function without making changes to the ActiveX
    source code?

    Please help
    Thanks


  • Mark Schupp

    #2
    Re: Pointers in ASP

    I don't think so.

    I haven't done may C++ com objects that return strings but I am pretty sure
    that you have to return the value by using pointers to VARIANT. That's what
    the methods I created used do and they work.

    Here are the key parts of a working function that returns a single string
    ( I've removed some code that doesn't affect returning the string):

    STDMETHODIMP CHTTPDloader::A SyncGet(BSTR strTargetURL, BSTR strDestDir, long
    nOptions, VARIANT* strDownloadID)
    {
    AFX_MANAGE_STAT E(AfxGetStaticM oduleState())

    USES_CONVERSION ;

    ASSERT( strDownloadID != NULL );
    if( strDownloadID == NULL )
    {
    return( E_POINTER );
    }

    try
    {

    CString strURL;
    CString strDestination;
    COleVariant vtOut;

    strURL = OLE2T( strTargetURL );
    strDestination = OLE2T( strDestDir );

    //clear any existing value
    vtOut.Attach( *strDownloadID );
    vtOut.Clear();

    vtOut.Detach();
    strDownloadID->vt = VT_BSTR;
    strDownloadID->bstrVal = (DoAsyncGet( strURL, strDestination,
    nOptions )).AllocSysStri ng();

    }
    catch(...)
    {
    return E_FAIL;
    }

    return S_OK;
    }



    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    Advancing limitless knowledge and continual growth to create confident problem solvers, one course at a time.



    "MeAndI" <sebabert@liber o.it> wrote in message
    news:P1OOb.2686 97$e6.10536454@ twister2.libero .it...[color=blue]
    > Hi to all,
    >
    > I've integrate a custom ActiveX (builded in C++) in my ASP pages, but now[/color]
    I[color=blue]
    > have a question/problem.
    > I have a function which uses the pointers as parameters.
    > When I call this function in my ASP page I have this error (Data type
    > missmatch..)
    > e.g.
    > dim param1
    > dim param2
    > param1 = ""
    > param2 = ""
    > retval = myActiveX.myFun ction (param1, param2)
    >
    > myFunction is declared as follow:
    > long CmyActiveXCtrl: :myFunction(BST R FAR* param1, BSTR FAR* param2)
    >
    > It is possible to call this function without making changes to the ActiveX
    > source code?
    >
    > Please help
    > Thanks
    >
    >[/color]


    Comment

    • MeAndI

      #3
      Re: Pointers in ASP

      OK Mark.
      Now I understand, thanks

      The problem happens because the pointer type is BSTR instead of VARIANT.
      But now I have another question for you:

      My ASP code is:

      <%
      objectTest = Server.CreateOb ject("myobject. progID")
      dim retval
      retval = objectTest.eFun ction()
      %>

      The object creation is done correctly, but when I call one function that
      doesn't need params I have the following error:
      0x8000FFFF (Catastrophic failure)

      Do you have thoughts?


      "Mark Schupp" <mschupp@ielear ning.com> ha scritto nel messaggio
      news:eoy85Cr3DH A.540@tk2msftng p13.phx.gbl...[color=blue]
      > I don't think so.
      >
      > I haven't done may C++ com objects that return strings but I am pretty[/color]
      sure[color=blue]
      > that you have to return the value by using pointers to VARIANT. That's[/color]
      what[color=blue]
      > the methods I created used do and they work.
      >
      > Here are the key parts of a working function that returns a single string
      > ( I've removed some code that doesn't affect returning the string):
      >
      > STDMETHODIMP CHTTPDloader::A SyncGet(BSTR strTargetURL, BSTR strDestDir,[/color]
      long[color=blue]
      > nOptions, VARIANT* strDownloadID)
      > {
      > AFX_MANAGE_STAT E(AfxGetStaticM oduleState())
      >
      > USES_CONVERSION ;
      >
      > ASSERT( strDownloadID != NULL );
      > if( strDownloadID == NULL )
      > {
      > return( E_POINTER );
      > }
      >
      > try
      > {
      >
      > CString strURL;
      > CString strDestination;
      > COleVariant vtOut;
      >
      > strURL = OLE2T( strTargetURL );
      > strDestination = OLE2T( strDestDir );
      >
      > //clear any existing value
      > vtOut.Attach( *strDownloadID );
      > vtOut.Clear();
      >
      > vtOut.Detach();
      > strDownloadID->vt = VT_BSTR;
      > strDownloadID->bstrVal = (DoAsyncGet( strURL, strDestination,
      > nOptions )).AllocSysStri ng();
      >
      > }
      > catch(...)
      > {
      > return E_FAIL;
      > }
      >
      > return S_OK;
      > }
      >
      >
      >
      > --
      > Mark Schupp
      > Head of Development
      > Integrity eLearning
      > www.ielearning.com
      >
      >
      > "MeAndI" <sebabert@liber o.it> wrote in message
      > news:P1OOb.2686 97$e6.10536454@ twister2.libero .it...[color=green]
      > > Hi to all,
      > >
      > > I've integrate a custom ActiveX (builded in C++) in my ASP pages, but[/color][/color]
      now[color=blue]
      > I[color=green]
      > > have a question/problem.
      > > I have a function which uses the pointers as parameters.
      > > When I call this function in my ASP page I have this error (Data type
      > > missmatch..)
      > > e.g.
      > > dim param1
      > > dim param2
      > > param1 = ""
      > > param2 = ""
      > > retval = myActiveX.myFun ction (param1, param2)
      > >
      > > myFunction is declared as follow:
      > > long CmyActiveXCtrl: :myFunction(BST R FAR* param1, BSTR FAR* param2)
      > >
      > > It is possible to call this function without making changes to the[/color][/color]
      ActiveX[color=blue][color=green]
      > > source code?
      > >
      > > Please help
      > > Thanks
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Mark Schupp

        #4
        Re: Pointers in ASP

        I would remove all code from the function except that needed to return the
        value. Make sure that there is no error with the empty function. Then
        gradually add code back in until the error returns. That will tell what is
        causing it.

        --
        Mark Schupp
        Head of Development
        Integrity eLearning
        Advancing limitless knowledge and continual growth to create confident problem solvers, one course at a time.



        "MeAndI" <sebabert@liber o.it> wrote in message
        news:W49Pb.2722 42$e6.10638552@ twister2.libero .it...[color=blue]
        > OK Mark.
        > Now I understand, thanks
        >
        > The problem happens because the pointer type is BSTR instead of VARIANT.
        > But now I have another question for you:
        >
        > My ASP code is:
        >
        > <%
        > objectTest = Server.CreateOb ject("myobject. progID")
        > dim retval
        > retval = objectTest.eFun ction()
        > %>
        >
        > The object creation is done correctly, but when I call one function that
        > doesn't need params I have the following error:
        > 0x8000FFFF (Catastrophic failure)
        >
        > Do you have thoughts?
        >
        >
        > "Mark Schupp" <mschupp@ielear ning.com> ha scritto nel messaggio
        > news:eoy85Cr3DH A.540@tk2msftng p13.phx.gbl...[color=green]
        > > I don't think so.
        > >
        > > I haven't done may C++ com objects that return strings but I am pretty[/color]
        > sure[color=green]
        > > that you have to return the value by using pointers to VARIANT. That's[/color]
        > what[color=green]
        > > the methods I created used do and they work.
        > >
        > > Here are the key parts of a working function that returns a single[/color][/color]
        string[color=blue][color=green]
        > > ( I've removed some code that doesn't affect returning the string):
        > >
        > > STDMETHODIMP CHTTPDloader::A SyncGet(BSTR strTargetURL, BSTR strDestDir,[/color]
        > long[color=green]
        > > nOptions, VARIANT* strDownloadID)
        > > {
        > > AFX_MANAGE_STAT E(AfxGetStaticM oduleState())
        > >
        > > USES_CONVERSION ;
        > >
        > > ASSERT( strDownloadID != NULL );
        > > if( strDownloadID == NULL )
        > > {
        > > return( E_POINTER );
        > > }
        > >
        > > try
        > > {
        > >
        > > CString strURL;
        > > CString strDestination;
        > > COleVariant vtOut;
        > >
        > > strURL = OLE2T( strTargetURL );
        > > strDestination = OLE2T( strDestDir );
        > >
        > > //clear any existing value
        > > vtOut.Attach( *strDownloadID );
        > > vtOut.Clear();
        > >
        > > vtOut.Detach();
        > > strDownloadID->vt = VT_BSTR;
        > > strDownloadID->bstrVal = (DoAsyncGet( strURL, strDestination,
        > > nOptions )).AllocSysStri ng();
        > >
        > > }
        > > catch(...)
        > > {
        > > return E_FAIL;
        > > }
        > >
        > > return S_OK;
        > > }
        > >
        > >
        > >
        > > --
        > > Mark Schupp
        > > Head of Development
        > > Integrity eLearning
        > > www.ielearning.com
        > >
        > >
        > > "MeAndI" <sebabert@liber o.it> wrote in message
        > > news:P1OOb.2686 97$e6.10536454@ twister2.libero .it...[color=darkred]
        > > > Hi to all,
        > > >
        > > > I've integrate a custom ActiveX (builded in C++) in my ASP pages, but[/color][/color]
        > now[color=green]
        > > I[color=darkred]
        > > > have a question/problem.
        > > > I have a function which uses the pointers as parameters.
        > > > When I call this function in my ASP page I have this error (Data type
        > > > missmatch..)
        > > > e.g.
        > > > dim param1
        > > > dim param2
        > > > param1 = ""
        > > > param2 = ""
        > > > retval = myActiveX.myFun ction (param1, param2)
        > > >
        > > > myFunction is declared as follow:
        > > > long CmyActiveXCtrl: :myFunction(BST R FAR* param1, BSTR FAR* param2)
        > > >
        > > > It is possible to call this function without making changes to the[/color][/color]
        > ActiveX[color=green][color=darkred]
        > > > source code?
        > > >
        > > > Please help
        > > > Thanks
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...