资源简介
一个实用的Demo,可以通过MTP(多媒体传输)协议和便携设备进行通信交互,读取便携设备信息,从便携设备upload\download文件。(微软官方例子)
代码片段和文件信息
// THIS CODE AND INFORMATION IS PROVIDED “AS IS“ WITHOUT WARRANTY OF
// ANY KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
#include “stdafx.h“
// This number controls how many object identifiers are requested during each call
// to IEnumPortableDeviceobjectIDs::Next()
//
#define NUM_objectS_TO_REQUEST 10
// Recursively called function which enumerates using the specified
// object identifier as the parent.
void RecursiveEnumerate(
_In_ PCWSTR objectID
_In_ IPortableDeviceContent* content)
{
ComPtrjectIDs> enumobjectIDs;
// Print the object identifier being used as the parent during enumeration.
wprintf(L“%ws\n“ objectID);
// Get an IEnumPortableDeviceobjectIDs interface by calling Enumobjects with the
// specified parent object identifier.
HRESULT hr = content->Enumobjects(0 // Flags are unused
objectID // Starting from the passed in object
nullptr // Filter is unused
&enumobjectIDs);
if (FAILED(hr))
{
wprintf(L“! Failed to get IEnumPortableDeviceobjectIDs from IPortableDeviceContent hr = 0x%lx\n“ hr);
}
// Loop calling Next() while S_OK is being returned.
while(hr == S_OK)
{
DWORD numFetched = 0;
PWSTR objectIDArray[NUM_objectS_TO_REQUEST] = {0};
hr = enumobjectIDs->Next(NUM_objectS_TO_REQUEST // Number of objects to request on each NEXT call
objectIDArray // Array of PWSTR array which will be populated on each NEXT call
&numFetched); // Number of objects written to the PWSTR array
if (SUCCEEDED(hr))
{
// Traverse the results of the Next() operation and recursively enumerate
// Remember to free all returned object identifiers using CoTaskMemFree()
for (DWORD index = 0; (index < numFetched) && (objectIDArray[index] != nullptr); index++)
{
RecursiveEnumerate(objectIDArray[index] content);
// Free allocated PWSTRs after the recursive enumeration call has completed.
CoTaskMemFree(objectIDArray[index]);
objectIDArray[index] = nullptr;
}
}
}
}
//
// Enumerate all content on the device starting with the
// “DEVICE“ object
//
void EnumerateAllContent(
_In_ IPortableDevice* device)
{
HRESULT hr = S_OK;
ComPtr content;
// Get an IPortableDeviceContent interface fro
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1268 2013-10-17 17:30 Portable Devices COM API Sample\C++\CommonFunctions.h
文件 12498 2013-10-17 17:30 Portable Devices COM API Sample\C++\ContentEnumeration.cpp
文件 47717 2013-10-17 17:30 Portable Devices COM API Sample\C++\ContentProperties.cpp
文件 69925 2013-10-17 17:30 Portable Devices COM API Sample\C++\ContentTransfer.cpp
文件 572 2014-02-16 21:35 Portable Devices COM API Sample\C++\Debug\WpdApiSample.log
文件 36813 2013-10-17 17:30 Portable Devices COM API Sample\C++\DeviceCapabilities.cpp
文件 17887 2013-10-17 17:30 Portable Devices COM API Sample\C++\DeviceEnumeration.cpp
文件 4426 2013-10-17 17:30 Portable Devices COM API Sample\C++\DeviceEvents.cpp
文件 1930 2013-10-17 17:30 Portable Devices COM API Sample\C++\ReadMe.txt
文件 1957 2013-10-17 17:30 Portable Devices COM API Sample\C++\stdafx.h
文件 11671 2013-10-17 17:30 Portable Devices COM API Sample\C++\WpdApiSample.cpp
文件 479232 2014-02-18 22:51 Portable Devices COM API Sample\C++\WpdApiSample.sdf
文件 2233 2013-10-17 17:30 Portable Devices COM API Sample\C++\WpdApiSample.sln
文件 3584 2014-02-18 22:51 Portable Devices COM API Sample\C++\WpdApiSample.suo
文件 10399 2013-10-17 17:30 Portable Devices COM API Sample\C++\WpdApiSample.vcxproj
文件 143 2014-02-16 21:33 Portable Devices COM API Sample\C++\WpdApiSample.vcxproj.user
文件 5834 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 71561 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 0 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 0 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 10455 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 7344 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 1727 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 1670 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 10721 2013-10-17 17:30 Portable Devices COM API Sample\desc
文件 4688 2013-10-17 17:30 Portable Devices COM API Sample\license.rtf
目录 0 2014-02-18 20:49 Portable Devices COM API Sample\C++\ipch\wpdapisample-db914964
目录 0 2014-02-16 21:35 Portable Devices COM API Sample\C++\Debug
目录 0 2014-02-18 20:49 Portable Devices COM API Sample\C++\ipch
目录 0 2014-02-18 22:51 Portable Devices COM API Sample\C++
............此处省略5个文件信息
相关资源
- MTP模式传输
- Qt下 基于smtp协议的邮件发送客户端源
- 简易的smtp服务器与客户端的C代码
- Qt实现smtp发送邮件
- VC完整的电子邮件客户端收发邮件用到
- EMTP ATP使用说明
- 基于EMTP的操作过电压仿真.rar
- 类Foxmail实现代码
- 使用Socket结合SMTP/POP3邮件协议发送和
- SMTP测试工具
- 基于ATP_EMTP的交流特高压试验示范工程
- SVPWM控制和MTPA控制
- Dimac.JMail.Smtp.dll 1.1版本
- 使用CDO和SMTP两种方式发送Email,解决
- VC发邮件源码
- MTP10-B1F55热电堆传感器.pdf
- Delphi 收发电子邮件仿Foxmail
- Internet协议分析-FTP报文分析-SMTP报文分
- SMTP发信 非易语言自带
- 易语言发邮件源码(smtp.qq.com)
- SMTP支持SSL
- RFC821(SMTP)中文版
评论
共有 条评论