Using Windows Portable Devices from c#
- From: listenfaster <benmca@xxxxxxxxx>
- Date: Tue, 12 Aug 2008 11:59:22 -0700 (PDT)
Hi Folks -
Does anyone know what MS's current position is on using the WPD API
from C# via COM interop?
I've found a few resources, three out of four MS resources:
http://blogs.msdn.com/dimeby8
http://code.google.com/p/zenses/
http://www.codeplex.com/WpdTempSensor
http://blogs.msdn.com/wpdblog/default.aspx
The blog postings all drop off around the beginning of 2008. What
happened?
I'm going to have to go to C++, because I can't get a transfer to the
device happening via the IStream returned by
CreateObjectWithPropertiesAndData. For posterity, here's as far as
I've gotten - maybe someone else has gotten stuck at the same spot and
can lend a hand:
<snip>
PortableDeviceClass dev = dm.GetDevice(LastDevice.Id);
if (dev != null)
{
IPortableDeviceContent contentRef = null;
dev.Content(out contentRef);
Stream streamToFile = new FileStream(destinationFile,
FileMode.Open, FileAccess.Read);
PortableDeviceValuesClass props = new PortableDeviceValuesClass();
SetProps(ref props, destinationFile, size);
PortableDeviceApiLib.IStream objStream = null;
uint bufSize = 0;
string cookie = string.Empty;
contentRef.CreateObjectWithPropertiesAndData((PortableDeviceApiLib.IPortableDeviceValues)props,
out objStream,
ref bufSize,
ref cookie);// last
param cookie - null in c++ sample
System.Runtime.InteropServices.ComTypes.IStream myStream =
(System.Runtime.InteropServices.ComTypes.IStream)objStream;
bool bRetry = false;
try
{
int bytesWritten =
StreamCopy(destinationStream,
myStream,
bufSize);
</snip>
....and so on. There is a Write operation on myStream in the
StreamCopy() method which throws a COMException:
System.Runtime.InteropServices.COMException (0x8007007A): The data
area passed to a system call is too small. (Exception from HRESULT:
0x8007007A).
I hope this helps anyone else looking into using WPD API interop. The
dimeby8 blog mentioned above hints at success in moving resources FROM
a device using the api, and I can iterate over connected devices and
get device properties just fine, so it's not entirely useless.
Ben McAllister
http://www.listenfaster.com
.
- Prev by Date: WMASFReader stream seek error.
- Next by Date: Avoiding playing files where codec is missing or format doesn't match extension
- Previous by thread: WMASFReader stream seek error.
- Next by thread: Avoiding playing files where codec is missing or format doesn't match extension
- Index(es):
Relevant Pages
|