开发者

Can't read WIA item timestamp object in C#

Hi all, I have a problem that I believe will end up a minor syntax problem. I hope. I am pulling data from a camera into an app using WIA 2.0 on a windows 7 machine using c#. The problem involves the timest开发者_运维知识库amp. I don't want to transfer the image until I check if its timestamp is within a range. Here is the chopped down important part of the code. The sample here is from my test harness where I just do everything in one fell swoop, not from the real code. Again, I can make everything work fine if I ignore time, but that isn't an option.

WIA.DeviceManager devMgr = new WIA.DeviceManager();  
foreach (DeviceInfo info in devMgr.DeviceInfos)   
{  
   if (info.Type == WiaDeviceType.CameraDeviceType) //grab the first camera   
   {   
     cameraDevice = info.Connect();   
     break;   
   }   
} 

Here there is a loop of i items in the camera (each item is a pic at this point)

WIA.Item item = cameraDevice.Items[i];    
timestamp = item.Properties.get_Item("Item Time Stamp").get_Value().ToString();  

Now on that last line it just returns System.__ComObject. I have no idea how to get the value out of this object, I can't cast/transmutate it to anything useful, it has no properties I can find. Can anyone help me with getting the value out of this timestamp object?

On a side note, its amazing how few samples there are in the world of people using c# and WIA. Just sayin.


This is what you want:

Vector timeTakenVector = (Vector)item.Properties["Item Time Stamp"].get_Value();
DateTime timeTaken = timeTakenVector.Date;


This one might help you

http://www.xtremevbtalk.com/archive/index.php/t-288758.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜