Monday, December 06, 2004

An ambitious project

The software I developed for my company, has performed well for our customers, causing them to choose it over offerings by Kodak (Groups) and PhotoLynx (SPS). The one shortcoming, photographers want the software tethered to the camera. That is, when the camera takes a picture, it is imediatly in the software, ready to be flagged with the student's information.

Well, Kodak does offer an SDK. It consists of 3 libraries (DLLs) and some sample code. The code is in C++ and was written using Visual Studio 6.0. My mission, that I've seemed to have accepted, is to write a managed code wrapper, using Visual Basic .Net, so that my software can consume and tether to the Kodak cameras.

Right now, I am at a standstill. I believe I have written code that will initialize and talk to the camera, but I don't have the cable to connect the camera to the PC for testing. So right now I get error codes from the .DLLs saying they can't initialize, which makes sense. But I also get this:
System.Runtime.InteropServices.MarshalDirectiveException: PInvoke restriction: can not return variants.

Here's the code that does it:
Dim myLibMgr As IntPtr = Marshal.AllocHGlobal(1)
Dim myCamIter As IntPtr = Marshal.AllocHGlobal(1)

myStatus = myPro4.KInitialize(KodakDCSIntf.Pro4.KPDCInitalizationOptions.KPDCInitOptionEnableIEEE1394, myLibMgr)

myStatus = myPro4.KAllocCamera(myLibMgr, myCamIter) <-----

I've wrapped the DLL like so:
Declare Auto Function KAllocCamera Lib "DCSPro4SLR.dll" Alias "KPDCAllocCameraIterator" (ByVal inManagerRef As IntPtr, ByRef outRef As IntPtr)

I think that it's not sure what to do, or the myLibMgr object is not valid. In the demo code, it doesn't get to AllocCamera if Initialize doesn't return a valid response (myStatus = 0).

No comments: