4

Have an old program I have been using to remotely control a digital camera, in order to automatically take photos and transfer them to the PC. Program is based on WIA and, as far as I remember, it was originally designed and used on Windows XP.

Recently took it out of the archives, and have been trying to get it to work on 64-bit Windows 7 using the same camera. Locating the camera, and triggering a capture works without issue. However when executing this line:

//device of type WIA.Device
Item item = device.ExecuteCommand(CommandID.wiaCommandTakePicture);

null is returned, leaving me without an image reference to transfer. Have been searching high and low for a solution, but have been unable to come up with anything. Found another QA site where an answer suggested that using:

//manager of type WIA.DeviceManager, device of type WIA.Device
manager.RegisterEvent(EventID.wiaEventItemCreated, device.DeviceID);
manager.OnEvent += new _IDeviceManagerEvents_OnEventEventHandler(manager_OnEvent);

one would receive events containing an itemID after image capture. Have tried this, and no event gets raised.

Thingfish
  • 113
  • 1
  • 3
  • 7
  • 1
    Was unable to find a solution, so I choose to install XP Mode for Windows 7 and run the program in the VM. – Thingfish Jan 28 '11 at 14:40
  • hi do you have the sample of your code, where you call the Device Manger dialog.. I am using something like this WIA.CommonDialog dlg = new WIA.CommonDialog(); and this is not working in XP but it works fine in Win 7. I have to do the same (taking pictures and saving it in disk on an XP machine.) – franklins Apr 22 '13 at 23:23

1 Answers1

0

In my experience, WIA has many oddities. I also struggled with the null returned by Item item = device.ExecuteCommand(CommandID.wiaCommandTakePicture); and though I am developing in Windows 7, my machine is 32-bit.

The solution, on my machine, is listening for the event as mentioned in the original question. If that's not working, try registering for the event using the wildcard device id:

manager.RegisterEvent(EventID.wiaEventItemCreated, Miscellaneous.wiaAnyDeviceID);
device.ExecuteCommand(CommandID.wiaCommandTakePicture);

I also found that I needed to re-register the event after each device command, otherwise it would stop triggering.

dcharles
  • 4,602
  • 1
  • 28
  • 29