共用方式為


DataTypeEnum

更新:2007 年 11 月

表示封包內物件的型別。

enum DataTypeEnum{
DT_INVALID = 0,
DT_BYTE = 1,
DT_INT32 = 2,
DT_WIDECHAR = 3,
DT_BOOL = 4,
DT_BYTEARRAY = 5,
DT_STRING = 6} DataTypeEnum;

備註

此列舉型別 (Enumeration) 可供 IPacket::ReadDataType 用來表示封包中資料的型別。

範例

在這個範例中,封包資料流會在連接的情況下,從桌面上的 RemoteAgent 物件讀取資料。如需完整的範例,請參閱IDeviceAgentTransport

// Check for a packet while communication stream is connected.
f2(&pPacket);
VARIANT_BOOL connected;
pStream->IsConnected(&connected);
while(connected)
{
    pStream->IsConnected(&connected);
    VARIANT_BOOL available;

    // If a packet is found, display the string.
    pStream->IsPacketAvailable(&available);
    if(available)
    {
        pStream->Read(&pPacket);
        VARIANT_BOOL endofpacket;
        pPacket->IsEndOfPacket(&endofpacket);
        while (!endofpacket) 

        {
            pPacket->IsEndOfPacket(&endofpacket);
            DataTypeEnum datatype;
            pPacket->ReadDataType(&datatype);
            switch (datatype)
            {
                case DT_BYTE:
                    BYTE byteValue;
                    pPacket->ReadByte(&byteValue);
                    break;
                case DT_INT32:
                    INT32 intValue;
                    pPacket->ReadInt32(&intValue);
                    break;
                case DT_WIDECHAR:
                    wchar_t charValue;
                    pPacket->ReadChar(&charValue);
                    break;
                case DT_BOOL:
                    VARIANT_BOOL boolValue;
                    pPacket->ReadBool(&boolValue);
                    break;
                case DT_BYTEARRAY:
                    BYTE * buffer[100];
                    ULONG length;
                    pPacket->ReadBytes(buffer,&length);
                    break;
                case DT_STRING:
                    LPWSTR string;
                    pPacket->ReadString(&string);
                    MessageBox(NULL, string,string,0);
                    break;
                default:
                    break;
            }
        };
    }
};

Managed 對應項

Microsoft.SmartDevice.DeviceAgentTransport.DataType

需求

DeviceAgentTransport.h

請參閱

其他資源

Unmanaged 裝置端智慧型裝置連接 API