最近用c#写过一个WPD的列子,主要是参考 c++的实例, 在 windows sdk 中 ( C:/Program Files/Microsoft SDKs/Windows/v7.0/Samples/multimedia/wpd/wpdapisample ) 由于 没有学习过 c++ ,所以看的不是很懂,在数据传输这里卡住了, 传输的时候是用 IStream 但是我不知道 这个 IStream 怎样实例化, c++ 里面是用的 (hr = SHCreateStreamOnFile(szFilePath, STGM_READ, &pFileStream)) ,希望请路过的大侠能指教一下。谢谢了。。。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PortableDeviceApiLib;
namespace MobileIntelligentPlatforms.WPDAPI
{
public class WPDAPP
{
private PortableDeviceManagerClass devMgr;
private PortableDeviceApiLib.PortableDeviceClass ppDevice;
/// <summary>
/// 获得设备ID,用于检查是否有设备接入
/// </summary>
/// <returns></returns>
public string[] getDeviceInfo()
{
devMgr = new PortableDeviceManagerClass();
uint cDevices = 1;
devMgr.GetDevices(null, ref cDevices);
if (cDevices > 0)
{
string[] deviceIDs = new string[cDevices];
devMgr.GetDevices(deviceIDs, ref cDevices);
return deviceIDs;
}
return null;
}
/// <summary>
/// 获得设备信息
/// </summary>
/// <param name="deviceID"></param>
/// <returns></returns>
public List<string> getFriendlyName(string deviceID)
{
List<string> msgs = new List<string>();
uint nameLength = 0;
devMgr.GetDeviceFriendlyName(deviceID, null, ref nameLength);