Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCoCreateInstance Timeout Pin
22-Dec-00 0:03
suss22-Dec-00 0:03 
GeneralRe: CoCreateInstance Timeout Pin
l a u r e n22-Dec-00 6:22
l a u r e n22-Dec-00 6:22 
GeneralRe: CoCreateInstance Timeout Pin
Julien26-Dec-00 11:24
Julien26-Dec-00 11:24 
GeneralRe: CoCreateInstance Timeout Pin
30-Dec-00 9:38
suss30-Dec-00 9:38 
GeneralCalling VB Com DLLs Pin
21-Dec-00 23:58
suss21-Dec-00 23:58 
GeneralRe: Calling VB Com DLLs Pin
l a u r e n22-Dec-00 6:26
l a u r e n22-Dec-00 6:26 
GeneralRe: Calling VB Com DLLs Pin
Julien26-Dec-00 11:36
Julien26-Dec-00 11:36 
GeneralRe: Calling VB Com DLLs Pin
30-Dec-00 9:33
suss30-Dec-00 9:33 
The DLL's are written by VB guys and one of the clients is using VC++, another client is the web.
Here is the source and Im getting 32 elements supposely returned by how would I access the string values of the array? Or is this code all screwed up?

VB6.0 COM DLL Code:

VBTest.cls
Public Function GetArray(ByVal s As String) As Variant

Dim retArray(32) As Variant
For i = 1 To UBound(retArray)
retArray(i) = "V" & CStr(i)
Next

GetArray = retArray

End Function

VC++ 6.0 Source:

test.idl
interface _clsTestCPP : IDispatch {
[id(0x60030000)]
HRESULT GetArray(
[in] BSTR s,
[out, retval] VARIANT* );

test.cpp
void main()
{
// Declare an HRESULT and a pointer to the clsVBTestClass interface
HRESULT hr;
_clsTestCPP *IVBTestClass = NULL;

// Now we will intilize COM
hr = CoInitialize(0);

// Use the SUCCEEDED macro and see if we can get a pointer
// to the interface
if(SUCCEEDED(hr))
{
hr = CoCreateInstance( CLSID_clsTestCPP,
NULL,
CLSCTX_INPROC_SERVER,
IID__clsTestCPP,
(void**) &IVBTestClass);

// If we succeeded then call the GetArray method,
// if it failed then display an appropriate message to the user.
if(SUCCEEDED(hr))
{
long ReturnValue;

_bstr_t bstrValue("Hello World");//dummy

SAFEARRAYBOUND rgsa[] ={32,0};//CAN I DO THIS AFTER GetArray() and dimension?
SAFEARRAY* pTempArray = SafeArrayCreate(VT_VARIANT, 1, rgsa);
VARIANT vArray;

//call Visual Basic function
hr = IVBTestClass->GetArray(bstrValue, &vArray);

// Get a pointer to the elements of the array.
HRESULT hr = SafeArrayAccessData(pTempArray, (void **)&vArray);
if (FAILED(hr)) return;

// Check dimensions of the array.
if (SafeArrayGetDim(pTempArray) != 1)
return;

// how many elements are there in the array - does return 32 elements
long lElements=(pTempArray)->rgsabound[0].cElements;

for (int j = 1; j < lElements; j++)
{
// NEED TO ACCESS STRING POINTERS

}


SafeArrayUnaccessData(pTempArray);

hr = IVBTestClass->Release();
}
else
{
// Something went wrong
cout << "CoCreateInstance Failed." << endl;
}
}

// Uninitialize COM
CoUninitialize();
}
GeneralRe: Calling VB Com DLLs Pin
31-Dec-00 6:02
suss31-Dec-00 6:02 
Questionwindows messages in numeric order? Pin
21-Dec-00 23:42
suss21-Dec-00 23:42 
AnswerRe: windows messages in numeric order? Pin
l a u r e n22-Dec-00 6:16
l a u r e n22-Dec-00 6:16 
AnswerRe: windows messages in numeric order? Pin
Michael Dunn22-Dec-00 16:35
sitebuilderMichael Dunn22-Dec-00 16:35 
GeneralRe: windows messages in numeric order? Pin
l a u r e n23-Dec-00 1:34
l a u r e n23-Dec-00 1:34 
Generalwindows address book file format Pin
l a u r e n21-Dec-00 19:30
l a u r e n21-Dec-00 19:30 
QuestionHow do I write a CBitmap to a file? Pin
21-Dec-00 10:24
suss21-Dec-00 10:24 
AnswerRe: How do I write a CBitmap to a file? Pin
Christian Graus21-Dec-00 10:30
protectorChristian Graus21-Dec-00 10:30 
Generalweb spider script wanted Pin
21-Dec-00 6:34
suss21-Dec-00 6:34 
Questionhow to change BackGroundColor? Pin
20-Dec-00 21:02
suss20-Dec-00 21:02 
AnswerRe: how to change BackGroundColor? Pin
Koceto21-Dec-00 0:58
Koceto21-Dec-00 0:58 
AnswerRe: how to change BackGroundColor? Pin
21-Dec-00 10:38
suss21-Dec-00 10:38 
GeneralRe: how to change BackGroundColor? Pin
21-Dec-00 12:53
suss21-Dec-00 12:53 
GeneralKim Pin
20-Dec-00 16:47
suss20-Dec-00 16:47 
GeneralRe: Kim Pin
Wesley Rogers21-Dec-00 11:03
Wesley Rogers21-Dec-00 11:03 
GeneralDialog Size Pin
20-Dec-00 16:02
suss20-Dec-00 16:02 
GeneralRe: Dialog Size Pin
Christian Graus20-Dec-00 18:53
protectorChristian Graus20-Dec-00 18:53 

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.