Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Pointers in ASP

Reply
Thread Tools

Pointers in ASP

 
 
MeAndI
Guest
Posts: n/a
 
      01-19-2004
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


 
Reply With Quote
 
 
 
 
Mark Schupp
Guest
Posts: n/a
 
      01-19-2004
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" <(E-Mail Removed)> wrote in message
news1OOb.268697$(E-Mail Removed).. .
> 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
>
>



 
Reply With Quote
 
 
 
 
MeAndI
Guest
Posts: n/a
 
      01-20-2004
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" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news1OOb.268697$(E-Mail Removed).. .
> > 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
> >
> >

>
>



 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      01-20-2004
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" <(E-Mail Removed)> wrote in message
news:W49Pb.272242$(E-Mail Removed).. .
> 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" <(E-Mail Removed)> ha scritto nel messaggio
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news1OOb.268697$(E-Mail Removed).. .
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointers, pointers, pointers... cerr C Programming 12 04-07-2011 11:17 PM
Does deleting a container of pointers also delete the (contained) pointers? Xamalek C++ 7 11-04-2003 04:17 PM
c++: pointers to pointers A C++ 3 10-29-2003 01:15 PM
pointers to pointers // exception handling error muser C++ 3 09-18-2003 06:19 PM
Template specialization of pointers with function pointers Phil C++ 1 09-16-2003 02:17 AM



Advertisments