Pointers in ASP

Discussion in 'ASP General' started by MeAndI, Jan 19, 2004.

  1. MeAndI

    MeAndI Guest

    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.myFunction (param1, param2)

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

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

    Please help
    Thanks
     
    MeAndI, Jan 19, 2004
    #1
    1. Advertising

  2. MeAndI

    Mark Schupp Guest

    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::ASyncGet(BSTR strTargetURL, BSTR strDestDir, long
    nOptions, VARIANT* strDownloadID)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState())

    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 )).AllocSysString();

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

    return S_OK;
    }



    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "MeAndI" <> wrote in message
    news:p1OOb.268697$...
    > 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.myFunction (param1, param2)
    >
    > myFunction is declared as follow:
    > long CmyActiveXCtrl::myFunction(BSTR 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, Jan 19, 2004
    #2
    1. Advertising

  3. MeAndI

    MeAndI Guest

    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.CreateObject("myobject.progID")
    dim retval
    retval = objectTest.eFunction()
    %>

    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" <> ha scritto nel messaggio
    news:...
    > 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::ASyncGet(BSTR strTargetURL, BSTR strDestDir,

    long
    > nOptions, VARIANT* strDownloadID)
    > {
    > AFX_MANAGE_STATE(AfxGetStaticModuleState())
    >
    > 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 )).AllocSysString();
    >
    > }
    > catch(...)
    > {
    > return E_FAIL;
    > }
    >
    > return S_OK;
    > }
    >
    >
    >
    > --
    > Mark Schupp
    > Head of Development
    > Integrity eLearning
    > www.ielearning.com
    >
    >
    > "MeAndI" <> wrote in message
    > news:p1OOb.268697$...
    > > 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.myFunction (param1, param2)
    > >
    > > myFunction is declared as follow:
    > > long CmyActiveXCtrl::myFunction(BSTR FAR* param1, BSTR FAR* param2)
    > >
    > > It is possible to call this function without making changes to the

    ActiveX
    > > source code?
    > >
    > > Please help
    > > Thanks
    > >
    > >

    >
    >
     
    MeAndI, Jan 20, 2004
    #3
  4. MeAndI

    Mark Schupp Guest

    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
    www.ielearning.com


    "MeAndI" <> wrote in message
    news:W49Pb.272242$...
    > 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.CreateObject("myobject.progID")
    > dim retval
    > retval = objectTest.eFunction()
    > %>
    >
    > 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" <> ha scritto nel messaggio
    > news:...
    > > 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::ASyncGet(BSTR strTargetURL, BSTR strDestDir,

    > long
    > > nOptions, VARIANT* strDownloadID)
    > > {
    > > AFX_MANAGE_STATE(AfxGetStaticModuleState())
    > >
    > > 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 )).AllocSysString();
    > >
    > > }
    > > catch(...)
    > > {
    > > return E_FAIL;
    > > }
    > >
    > > return S_OK;
    > > }
    > >
    > >
    > >
    > > --
    > > Mark Schupp
    > > Head of Development
    > > Integrity eLearning
    > > www.ielearning.com
    > >
    > >
    > > "MeAndI" <> wrote in message
    > > news:p1OOb.268697$...
    > > > 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.myFunction (param1, param2)
    > > >
    > > > myFunction is declared as follow:
    > > > long CmyActiveXCtrl::myFunction(BSTR 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, Jan 20, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil
    Replies:
    1
    Views:
    671
    llewelly
    Sep 16, 2003
  2. muser
    Replies:
    3
    Views:
    784
    Ron Natalie
    Sep 18, 2003
  3. A
    Replies:
    3
    Views:
    479
    Alan Kelon
    Oct 29, 2003
  4. Xamalek
    Replies:
    7
    Views:
    708
  5. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    736
Loading...

Share This Page