 |
| C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

August 7th, 2003, 05:02 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

August 8th, 2003, 05:47 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Forward declaration of the IID of the UDT in .cpp file should solve the
problem.
insert this code before the function implementations.
Code:
const IID UUID_FGrid_t = { 0x31286171, 0xD2F8,0x11d5, { 0x9B,0x78,0x00,0xB0,0xD0,0x78,0xCA,0x0B} };
here I've just formated the IID you associated with your UDT
in your IDL file.
Regards
Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
|

August 8th, 2003, 05:52 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hello thanks for your answer. i will try this.
i did also solve the basic problem: i was using the wrong idl compiler
(version 5.01....) after switching to VC7 everything works great now. not with your solution but with __uuidof(vartype)
thanks
ps: there will be some more questions on com coming from me in the next time :) hope to get answers that fast againe
|

April 21st, 2005, 07:57 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello
Please post your complete IDL file here.
I have the same problem even if I compiled with VS.NET 2003 compiler.
Thanks in advance.
Quote:
quote:Originally posted by polderudo
hello thanks for your answer. i will try this.
i did also solve the basic problem: i was using the wrong idl compiler
(version 5.01....) after switching to VC7 everything works great now. not with your solution but with __uuidof(vartype)
thanks
ps: there will be some more questions on com coming from me in the next time :) hope to get answers that fast againe
|
|
|
 |