I am currently trying to link a camera to NAV2009 (Windows 7 Enterprise) so users can photograph incoming items. I have found a code sample using wiaaut.dll:
Globals:
- DeviceManager Automation 'Microsoft Windows Image Acquisition Library v2.0'.DeviceManager
- DeviceInfo Automation 'Microsoft Windows Image Acquisition Library v2.0'.DeviceInfo
- Device Automation 'Microsoft Windows Image Acquisition Library v2.0'.Device
- Item Automation 'Microsoft Windows Image Acquisition Library v2.0'.Item
- ImageFile Automation 'Microsoft Windows Image Acquisition Library v2.0'.ImageFile
- Index Integer
OnRun()
// Create the WIA device manager
CREATE(DeviceManager);
// Return the device info for the first WIA-compatible device;
Index := 1;
DeviceInfo := DeviceManager.DeviceInfos.Item(Index);
// Connect to the first device
Device := DeviceInfo.Connect;
// Take picture
Item := Device.ExecuteCommand(wiaCommandTakePicture);
// Store the image file
ImageFile := Item.Transfer;
ImageFile.SaveFile('c:\temp\test.bmp');
procedure wiaCommandTakePicture() : Text[50]
EXIT('{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}');
The sample runs just fine up until the 'store image' section. There, I get an error on the 'ImageFile := Item.Transfer' statement, saying that no instance of the automation variable has been created. I added the statement CREATE(Item), but this returns an error as well. Although I can select the Windows Image Acquisition v2.0 library in the automation list, the library doesn't show in the Custom Controls list, nor can I register wiaaut.dll there. Does anyone have an idea what is going on here?
0
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
"Item.Transfer is returning NULL": I gathered as much, question is why?
Thanks for your help.
Hope this helps
Thomas
Change Index to different Number
Change the code to
Device := DeviceManager.DeviceInfos.Item(Index).Connect;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n