LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Barcode cvi

I’m using a Symbol fixed barcode scanner model MS-4407HD which came with a DLL.  I’m trying to Init the scanner using the function called from the supplied DLL but with no luck so far. I’m using CVI  6.x

 

WindowHandle = (HWND)GetCVIWindowHandle();

 

Here is my call to SNAPI_Init()

BarcodeStatus = SNAPI_Init(WindowHandle, DeviceHandles, NumDevices);

 

My call into the DLL gives an error  “The program has caused a first chance General Protection Fault..”

 

I’m lost!  Can any of you lend a hand to guide me through this issue?

 After a lot of searching I think I found how to send the HWND to the above call.  I don't fully understand the handle to this particular window.  Maybe I need a canvas and a handle to that, which is where the barcode image would appear??

  From the programmer manual:

SNAPI_Init Initializing command that registers the window that will receive Windows messages from the library. It returns an array of the Symbol Image scanners that are connected to the host through USB.

 SNAPI_Init Lifecycle CommandInitializing command that registers the window that will receive Windows messages from the library. It returns an array of the Symbol Image scanners that are connected to the host through USB. No command is sent to the scanner during this API call.SyntaxSNAPIDLL_API int __stdcall SNAPI_Init(HWND hwnd,HANDLE *DeviceHandles,int *NumDevices);ParametershwndThe handle of the window whose procedure will receive Windows messages from the library.DeviceHandlesA pointer to an array that will store handles for the devices that are found.NumDevicesPointer to the number of devices that were found.Return ValuesSSICOMM_NOERROR – The device connected successfully.An error code if an error occurred. (See Table 1-2 on page 1-8.)ExampleHANDLE devicehandle[MAX_SCANNER]={0};int NumScanners=0;int status;

status = SNAPI_Init(m_hWnd, devicehandle, & NumScanners);

 Thank you for any help, Randy   
0 Kudos
Message 1 of 3
(3,794 Views)

I'm guessing that your NumDevices is a plain int. In that case, the call into the dll should pass a pointer to this variable:

 

    BarcodeStatus = SNAPI_Init(WindowHandle, DeviceHandles, &NumDevices); 

 

as shown in the last line of the programmer manual text.

 

JR

Message 2 of 3
(3,788 Views)

Thank you!  No doubt you can tell my inexperience with C.  Your solution helped.  I'm not there yet, but your suggestion eliminated the GPF.  I still have something wrong with DeviceHandles[] sent with the SNAPI_Connect(DeviceHandles[0]) call.

 

It's defined as: " HANDLE DeviceHandles[15]; "  

 

Thank you again!

 

Randy

0 Kudos
Message 3 of 3
(3,764 Views)