共用方式為


IDevicePacketStream::Write

更新:2007 年 11 月

將封包寫入至資料流。封包是由桌上型電腦上的 DevicePacketStream 所讀取。

HRESULT Write([in] IPacket *in_pPacket)

參數

  • in_pPacket
    要寫入的封包。

傳回值

HRESULT 值,表示方法呼叫的結果。

  • E_INVALIDARG | 輸入引數無效 (封包為 NULL 指標)。

  • E_FAIL | 任何其他失敗。

範例

在這個範例中,IDeviceAgentTransport::AcceptConnectionEx 會建立 IDevicePacketStream 的執行個體。接著便會使用裝置封包資料流,將資料寫入至桌面上的 RemoteAgent 物件。如需完整的範例,請參閱IDeviceAgentTransport

// Let the desktop application know that this remote agent was deployed successfully 
// and that this remote agent will handle the supplied list of services.
LPCOLESTR szServiceIds[] = {L"F85E57BA-5AE9-4FF7-8433-6AB7D991D033"};
pTransport->AcknowledgeLaunch(1, szServiceIds);

// Open a communcation stream with desktop application on the service.
IDevicePacketStream *pStream = NULL;
pTransport->AcceptConnectionEx(szServiceIds[0], &pStream);

// Get an instance of IPacket
GetNewPacketFunc f2 = (GetNewPacketFunc) ::  GetProcAddress(hmod, L"GetNewPacket");
IPacket *pPacket = NULL;
f2(&pPacket);

// Write a message and sent the packet.
pPacket->WriteBool(true);
pPacket->WriteByte(0xff);
pPacket->WriteChar('c');
pPacket->WriteInt32(1024);
pPacket->WriteString(L"Hello Desktop Computer");
pStream->Write(pPacket);

Managed 對應項

IDevicePacketStream.Write

需求

DeviceAgentTransport.h

請參閱

參考

IDevicePacketStream