Pointers in ASP

M

MeAndI

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
 
M

Mark Schupp

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;
}
 
M

MeAndI

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?
 
M

Mark Schupp

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top