atl programming . help me..plz .. how to use SafeArrary.???

M

MakeFeel

hi.

i made ReverseArrary() and
i wanna Get PACKET Struct in ReverseArrary of function
but i don't know that's error..

How to Use SafeArrary ???

can u help plz..!!!
------------------DAgent.h----------------------
// DAgent.h

#pragma once
#include "resource.h"

#include "Binding.h"


typedef struct _PACKET {
HANDLE hEvent; ///< \deprecated Still present for
compatibility with old applications.
OVERLAPPED OverLapped; ///< \deprecated Still present for
compatibility with old applications.
PVOID Buffer; ///< Buffer with containing the
packets. See the PacketReceivePacket() for
///< details about the
organization of the data in this buffer
UINT Length; ///< Length of the buffer
DWORD ulBytesReceived; ///< Number of valid bytes present in the
buffer, i.e. amount of data
///< received by the last
call to PacketReceivePacket()
BOOLEAN bIoComplete; ///< \deprecated Still present for
compatibility with old applications.
} PACKET, *LPPACKET;

// IDAgent
[
object,
uuid("F8CB9753-F5D0-4A4F-B1DE-9823714C1B41"),
dual, helpstring("IDAgent interface"),
pointer_default(unique)
]
__interface IDAgent : IDispatch
{
[id(0), helpstring("Create Bind")] HRESULT CreateBind();
[id(1), helpstring("Send Pakcet")] HRESULT Send([in] short bData,
[out,retval] BSTR* pstrTime);
[id(2), helpstring("ReverseArray")] HRESULT ReverseArray([in ]
(tagSAFEARRAY)PACKET *p );
};



// CDAgent

[
coclass,
threading("apartment"),
vi_progid("SendServer.DAgent"),
progid("SendServer.DAgent.1"),
version(1.0),
uuid("FF741DED-441D-4F96-AF45-2A831B581FEF"),
helpstring("DAgent Class")
]
class ATL_NO_VTABLE CDAgent :
public IDAgent
{
public:
CBINDING *m_pBind;

public:
CDAgent()
{
SetBind();
}


DECLARE_PROTECT_FINAL_CONSTRUCT()

HRESULT FinalConstruct()
{
return S_OK;
}

void FinalRelease()
{
if( m_pBind != NULL ) delete m_pBind;
}

public:
CBINDING *GetBind(){ return m_pBind; }
void SetBind(){ m_pBind = new CBINDING(); }



public:
STDMETHODIMP CreateBind();
STDMETHODIMP Send(short bData, BSTR* pstrTime);
STDMETHOD(ReverseArray)(struct tagSAFEARRAY **sp);
};
 
V

Vladimir Nesterovsky

i made ReverseArrary() and
i wanna Get PACKET Struct in ReverseArrary of function
but i don't know that's error..

How to Use SafeArrary ???

can u help plz..!!!

In order to work with safe array in ATL you can use ATL::CComSafeArray
template.
You should know however that safe arrays operate over limited set of element
types.
Your PACKET does not fit into safe array easily.
 
Top