IDeviceAgentTransport::AcceptConnectionEx

更新:2007 年 11 月

接受在台式计算机上调用 CreatePacketStream 时启动的连接。随后,该方法将准备供数据传输使用的设备数据包流参数。

HRESULT AcceptConnectionEx([full][in] LPCOLESTR in_szServiceId, [out] IDevicePacketStream **out_pDevicePacketStream)

参数

  • in_szServiceId
    要接受其连接的服务 ID。

  • out_pDevicePacketStream
    一个指针,它指向执行数据传输的设备数据包流对象。

返回值

一个指示方法调用结果的 HRESULT 值。

备注

只能接受具有已用 IDeviceAgentTransport::AcknowledgeLaunch 注册的服务 ID 的连接。

示例

此示例将接受从台式机应用程序的 CreatePacketStream 创建数据包流的请求。有关完整的示例,请参见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);

托管等效项

IDeviceAgentTransport.AcceptConnectionEx

要求

DeviceAgentTransport.h

请参见

参考

IDeviceAgentTransport