View Single Post
  #1 (permalink)  
Old August 7th, 2003, 05:02 AM
polderudo polderudo is offline
Registered User
 
Join Date: Aug 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to polderudo
Default How to Pass a UDT from ATL to VB via COM-EXE-SERVE

hello

i am having some problems passing some UDT via con from C++ to VB in an SAFEARRAY.
there allready exists a thread describing how to do this but when i try to compile the code i get an error.

here the code in the idl file:

struct tagFGrid_t
{
    double Easting;
    double Northing;
    double Height;
};
typedef
[
    uuid(31286171-D2F8-11d5-9B78-00B0D078CA0B),
    helpstring("FGrid_t structure")
]
struct tagFGrid_t FGrid_t;
....

(in the interface)
[id(3), helpstring("Methode test1")] HRESULT XSendManyStructs([out, retval] SAFEARRAY(struct tagFGrid_t) * psaProfile);

....

//==================

now the code in the .cpp file
STDMETHODIMP CStrSrvClass::XSendManyStructs(/*[out, retval] SAFEARRAY(FGrid_t) */ LPSAFEARRAY * psaProfile)
{
    LPSAFEARRAY lpsaGrid = NULL;
    SAFEARRAYBOUND rgbounds = { 0, 1 };
    IRecordInfo* pRecInfo = NULL;
    HRESULT hr;

    hr = GetRecordInfoFromGuids(LIBID_STRUCTSRVLib, 1, 0, GetUserDefaultLCID(), UUID_FGrid_t, &pRecInfo);
    if (!SUCCEEDED(hr) || !pRecInfo)
    {
        return Error("FAnchoringDevice.get_Profile: failed to get UDT information for FCatenaryGridProfile_t", GUID_NULL, hr);
    }

    // Initialize number of elements of Array.
    rgbounds.cElements = 3;

    lpsaGrid = SafeArrayCreateEx(VT_RECORD, 1, &rgbounds, pRecInfo);
    pRecInfo->Release();

    // Do your stuff here to fill in the data of the SAFEARRAY

    *psaProfile = lpsaGrid;
    return S_OK;
}


//=============
when i compile the code i get the error:
D:\projects\temp\StructSrv\StrSrvClass.cpp(77) : error C2065: 'UUID_FGrid_t' : nichtdeklarierter Bezeichner
means "undeclared idetifyer"

i also tryed

hr = GetRecordInfoFromGuids(LIBID_STRUCTSRVLib, 1, 0, GetUserDefaultLCID(), __uuidof(FGrid_t), &pRecInfo);
but then i get the error:

D:\projects\temp\StructSrv\StrSrvClass.cpp(77) : error C2787: 'tagFGrid_t' : Keine GUID mit diesem Objekt verbunden
means " no GUID assosiated to object"



many thanks in advance
Reply With Quote