[prev in list] [next in list] [prev in thread] [next in thread]
List: ms-atl
Subject: Re: Passing GUIDs as Method Arguments
From: Stan Gibbs <stan_gibbs () OM ! CV ! HP ! COM>
Date: 1997-07-31 19:00:53
[Download RAW message or body]
IErrorInfo is not an oleautomation compatible interface (it doesn't
have the [oleautomation] attribute in oaidl.idl), so GUID is allowed.
Stan
______________________________ Reply Separator _________________________________
Subject: Re: Passing GUIDs as Method Arguments
Author: Non-HP-ATL (ATL@LISTSERV.MSN.COM) at HP-Corvallis,mimegw1
Date: 7/31/97 9:14 AM
How is this defined in the IDL? Whenever, I define a method to pass a
GUID, I get the following MIDL compiler error.
interface IPassGuid : IDispatch
{
[id(1), helpstring("method PassGuid")] HRESULT PassGuid([out]
GUID* lpGuid);
};
.\guid.idl(24) : warning MIDL2039 : interface does not conform to
[oleautomation] attribute : [ Parameter 'lpGuid' of Procedure 'PassGuid'
( Interface 'IPassGuid' ) ]
However, this is exactly the way the following interface is defined in
Oaidl.idl:
interface IErrorInfo: IUnknown
{
typedef [unique] IErrorInfo * LPERRORINFO;
HRESULT GetGUID(
[out] GUID * pGUID
);
> -----Original Message-----
> From: Anne Chinn (RhoTech) [SMTP:a-annech@MICROSOFT.COM]
> Sent: Thursday, July 31, 1997 11:32 AM
> To: ATL@LISTSERV.MSN.COM
> Subject: Re: Passing GUIDs as Method Arguments
>
> The Repository interfaces pass around GUIDs as VARIANTS. The
> data is stored as a SAFEARRAY of VT_UI1. When packaging up a GUID
> to send you use the class below, CGuidVariant, which will initialize
> the
> SAFEARRAY with the GUID. When unpackaging you would just extract
> the GUID from the VARIANT using the SafeArrayAccessData methods.
>
>
> Packaging GUID into a VARIANT:
>
> CGuidVariant v(CLSID_SOMEOBJECT);
>
> Unpackaging GUID from VARIANT:
>
> CComVariant guid_variant;
> GUID *guid;
>
> if (FAILED(hr = SafeArrayAccessData(guid_variant.parray,
> (void**)&guid)))
> ReturnError(hr);
>
> if (FAILED(hr = SafeArrayUnaccessData(guid_variant.parray)))
> ReturnError(hr);
>
>
> CGuidVariant class initializes the parray member of the VARIANT with
> the
> GUID.
>
> class CGuidVariant : public CComVariant
> {
> public:
> CRepVariant() :
> CComVariant()
> {
> }
>
> CRepVariant(REFGUID guid)
> {
> ::VariantInit(this);
> InitSafeArrayLen((BYTE *)&guid, sizeof(GUID));
> }
>
> CRepVariant &operator=(REFGUID guid)
> {
> ::VariantClear(this);
> InitSafeArrayLen((BYTE *)&guid, sizeof(GUID));
> return (*this);
> }
>
> inline SAFEARRAY * InitSafeArrayLen(BYTE *pData, size_t iSize)
> {
> if ((this->parray = AllocSafeArrayLen(pData, iSize))
> !=
> NULL)
> this->vt = VT_UI1 | VT_ARRAY;
> else
> {
> this->vt = VT_EMPTY;
> }
> return (this->parray);
> }
> };
>
> inline SAFEARRAY *AllocSafeArrayLen( // Return status.
> BYTE *pData, //
> Data
> to be placed in the array.
> size_t iSize) //
> Size
> of data.
> {
> SAFEARRAYBOUND sBound; // Used to
> fill
> out the bounds.
> SAFEARRAY *pArray = 0; // Ptr to the
> new array.
>
> sBound.cElements = iSize;
> sBound.lLbound = 0;
> if ((pArray = SafeArrayCreate(VT_UI1, 1, &sBound)) != NULL)
> memcpy(pArray->pvData, (void *) pData, iSize);
> return (pArray);
> }
>
> Anne
>
> > -----Original Message-----
> > From: Shailesh Shah [SMTP:Shailesh_Shah@INFINIUM.COM]
> > Sent: Thursday, July 31, 1997 7:51 AM
> > To: ATL@LISTSERV.MSN.COM
> > Subject: Re: Passing GUIDs as Method Arguments
> >
> > >>Does anyone have any code snippets that pass guids as arguments in
> > an
> > >>interface method back and forth from an ATL local server(EXE) to a
> > VB5.0
> > >>client?
> >
> > AFAIK, VB doesnt support non-automation typs such as GUID.
> >
> > ----------------------------------------------------------------
> > Users Guide
> http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
> > contains important info including how to unsubscribe. Save time,
> > search
> > the archives at http://microsoft.ease.lsoft.com/archives/index.html
>
> ----------------------------------------------------------------
> Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
> contains important info including how to unsubscribe. Save time,
> search
> the archives at http://microsoft.ease.lsoft.com/archives/index.html
----------------------------------------------------------------
Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://microsoft.ease.lsoft.com/archives/index.html
----------------------------------------------------------------
Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://microsoft.ease.lsoft.com/archives/index.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic