Click here to Skip to main content
15,915,611 members
Home / Discussions / COM
   

COM

 
GeneralRe: creating a com component from an IDL file Pin
vista274-Nov-04 17:26
vista274-Nov-04 17:26 
GeneralRe: creating a com component from an IDL file Pin
ThatsAlok4-Nov-04 18:30
ThatsAlok4-Nov-04 18:30 
GeneralRe: creating a com component from an IDL file Pin
vikramlinux5-Nov-04 0:23
vikramlinux5-Nov-04 0:23 
GeneralWMFormat SDK problem while read a .wmv Pin
ytod3-Nov-04 22:40
ytod3-Nov-04 22:40 
GeneralAbout Runtime and Developer Component Pin
ThatsAlok3-Nov-04 20:30
ThatsAlok3-Nov-04 20:30 
GeneralRe: About Runtime and Developer Component Pin
Sir Garence15-Nov-04 5:44
sussSir Garence15-Nov-04 5:44 
GeneralRe: About Runtime and Developer Component Pin
ThatsAlok15-Nov-04 17:31
ThatsAlok15-Nov-04 17:31 
GeneralCOM Component Returning An Array to VBScript Pin
Doug Knudson3-Nov-04 4:32
Doug Knudson3-Nov-04 4:32 
Hi All,

In VC++ 6, I have created a simple COM component that contains a single method on a single interface that returns a 2 dimensional SafeArray (3 columsn, variable number of rows) wrapped by a VARIANT. I tested the component from a C++ test app and the data is returned in the Variant/SafeArray and can be extracted using conventional means, and all is well. This whole process took about 3 hours. I have spent the last 4 days trying to get the component to work when instantiated in ASP code (VBScript). Sorry for this long post but I want to include as much info as I can in hopes that some kind soul will help.

The component was created with a single control (Simple Object). The function looks like this...

STDMETHODIMP CSiteSearch::SearchHTM(BSTR searchPath, BSTR searchPhrase, VARIANT *pSearchResults)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())


..................
Guts of function here to generate three CStringArrays (documentTypeArray,documentPathArray and documentContextArray) to be packed into the SafeArray and then wrapped by the Variant
..................

// Now stuff the safe array and return the data
DWORD numElements[2];
numElements[0] = 3;
numElements[1] = documentTypeArray.GetSize();

COleSafeArray sa;
sa.Create(VT_BSTR,2,numElements);

long elementIndex[2];
BSTR bData;

for (int row = 0; row < documentTypeArray.GetSize(); row++)
{

// Insert each column into the SafeArray
elementIndex[0] = 0;
elementIndex[1] = row;

bData = _bstr_t(documentTypeArray.GetAt(row));
sa.PutElement(elementIndex,bData);

elementIndex[0] = 1;
elementIndex[1] = row;

bData = _bstr_t(documentPathArray.GetAt(row));
sa.PutElement(elementIndex,bData);

elementIndex[0] = 2;
elementIndex[1] = row;

bData = _bstr_t(documentContextArray.GetAt(row));
sa.PutElement(elementIndex,bData);

}


// Return the array in a variant
CComVariant cVar;
cVar.Attach(pSearchResults);
cVar.Copy(sa);
cVar.Detach(pSearchResults);


}

return S_OK;
}


This works fine when called from a VC++ dialog based, client app (importing the type library).


The ASP/VBScript code that does not work looks like this...


' The creation of the control and the call of the method works without error
Set searchControl = Server.CreateObject("WebSiteSearch.SiteSearch.1")
theResults = searchControl.SearchHTM ( "C:\SomeFolderToSearch", searchPhrase )


' The following code does indeed identify the returned value (theResults) as an array... so, so far so good!
if (IsArray(theResults)) then
Response.Write("Its an Array")
else
Response.Write("Not an Array")
end if


' The following two lines return 0 and 2 respectively which is right, for one dimension of the array. The array should have 3 columns and a variable number of rows
Response.Write("Lower: " & LBound(theResults))
Response.Write("Upper: " & UBound(theResults))


' This fails!!!
Response.Write( theResults (0,0) )



' The error in the IIS 6.0 error log leads me to believe that VBScript does not recognize theResults as a two dimensional array (puzzling because the VC++ client does recognize the contents of the Variant as a two dimensional array) and is:


2004-11-03 15:21:17 GET /SearchResults.asp SearchFor=Code|25|800a000d|Type_mismatch:_'theResults' - 500 0


Any and all ideas would be GREATLY, GREATLY appreciated!
Thanks,
Doug

Doug Knudson
GeneralRe: COM Component Returning An Array to VBScript Pin
Vi25-Nov-04 3:19
Vi25-Nov-04 3:19 
GeneralOK. Component Services (COM+) crashes (?) Pin
CherezZaboro2-Nov-04 5:40
CherezZaboro2-Nov-04 5:40 
GeneralAccessing ActiveX control of other process Pin
Behlool1-Nov-04 19:00
Behlool1-Nov-04 19:00 
GeneralCoCreateInstance Failure Pin
skrishnasarma31-Oct-04 22:44
skrishnasarma31-Oct-04 22:44 
GeneralRe: CoCreateInstance Failure Pin
User 2155972-Nov-04 18:19
User 2155972-Nov-04 18:19 
GeneralRe: CoCreateInstance Failure Pin
skrishnasarma2-Nov-04 21:21
skrishnasarma2-Nov-04 21:21 
GeneralRe: CoCreateInstance Failure Pin
User 2155974-Nov-04 17:03
User 2155974-Nov-04 17:03 
GeneralRe: CoCreateInstance Failure Pin
skrishnasarma4-Nov-04 21:38
skrishnasarma4-Nov-04 21:38 
GeneralCLSID for TAPI Pin
asif m@hmood30-Oct-04 7:08
asif m@hmood30-Oct-04 7:08 
GeneralRe: CLSID for TAPI Pin
ThatsAlok5-Nov-04 2:40
ThatsAlok5-Nov-04 2:40 
Generalcreate a simple hex editor Pin
CD_ROM30-Oct-04 3:58
CD_ROM30-Oct-04 3:58 
GeneralRe: create a simple hex editor Pin
ThatsAlok3-Nov-04 17:19
ThatsAlok3-Nov-04 17:19 
GeneralUniquness of GUID of COM Pin
Ranjish29-Oct-04 19:44
Ranjish29-Oct-04 19:44 
GeneralRe: Uniquness of GUID of COM Pin
ThatsAlok29-Oct-04 20:55
ThatsAlok29-Oct-04 20:55 
GeneralRe: Uniquness of GUID of COM Pin
Ranjish29-Oct-04 21:01
Ranjish29-Oct-04 21:01 
GeneralRe: Uniquness of GUID of COM Pin
ThatsAlok29-Oct-04 21:10
ThatsAlok29-Oct-04 21:10 
GeneralRe: Uniquness of GUID of COM Pin
Ranjish29-Oct-04 21:15
Ranjish29-Oct-04 21:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.