Problem passing SAFEARRAY of UDTs to Server
I'm currently working on passing some data to a Server for processing
and i will need to pass an array of structures.
I have created a DLL INPROC Server to test this out, the IDL is as
follows:
import "oaidl.idl";
import "ocidl.idl";
typedef [uuid(E7524E2E-7C6E-4787-8B02-EEB81E639A41),
helpstring("Test Structure") ]
struct TACSTRUCT
{
short nID;
short nHdg;
float fLat;
float fLon;
float fHdg;
}TACSTRUCT;
[
object,
uuid(151F007A-5098-46F8-8BD5-D223EAA2E3BB),
dual,
helpstring("ITStructParserTest Interface"),
pointer_default(unique)
]
interface ITStructParserTest : IDispatch
{
[id(1), helpstring("method TParse")] HRESULT TParse([in]
SAFEARRAY(struct TACSTRUCT) *ppTArray);
};
[
uuid(EEBBA53C-4EE3-414F-A33B-D3B66D1D16F0),
version(1.0),
helpstring("TStructureParsing 1.0 Type Library")
]
library TSTRUCTUREPARSINGLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[
uuid(5BCBEEF1-AC96-47FA-B95B-0724833BC03B),
helpstring("TStructParserTest Class")
]
coclass TStructParserTest
{
[default] interface ITStructParserTest;
};
struct TACSTRUCT;
};
This compiles but gives me the warning warning MIDL2039 : interface
does not conform to [oleautomation] attribute : [ Parameter 'ppTArray'
of Procedure 'TParse' ( Interface 'ITStructParserTest' ) ]
The remaining problem i have is the client software, courtesy of
several other google posts i have created the following:
CoInitialize(0);
HRESULT hr = CoCreateInstance(__uuidof(TStructParserTest), NULL,
CLSCTX_INPROC_SERVER, IID_ITStructParserTest,
reinterpret_cast<void**>(&m_ptrTest));
if(SUCCEEDED(hr))
{
SAFEARRAY *psa;
SAFEARRAYBOUND sab = {2, 0};
TACSTRUCT *pData;
IRecordInfo *pRI;
HRESULT hr;
hr = GetRecordInfoFromGuids(LIBID_TSTRUCTUREPARSINGLib, 1, 0, 0x409,
__uuidof(TACSTRUCT), &pRI);
psa = SafeArrayCreateEx(VT_RECORD, 1, &sab, pRI);
pRI->Release();
pRI = NULL;
hr = SafeArrayAccessData(psa, (void**)&pData);
hr = SafeArrayUnaccessData(psa);
m_ptrTest->TParse(&psa);
}
CoUninitialize();
This fails to compile with the following: error C2787: 'TACSTRUCT' : no
GUID has been associated with this object
This has been driving my nuts for a few days now and any help would be
appreciated.