Open() requests a handle to the named device, and should work if the device exists. Close() is the matching pair function, and it should be called when the device is no longer needed by the application.
ClaimDevice() (previously known as the Claim() method) will attempt to access the device. If the device is an exclusive-use device (such as a barcode scanner), ClaimDevice() will fail if a different process has already claimed it. ReleaseDevice() (also known as Release() but it's name conflicted with the COM method Release()) is the matching pair function that should be called when the application no longer needs to access the device. This enables graceful sharing of devices between applications. An example might be if you have a button on your sales application to enter the inventory application - the sales application should call ReleaseDevice() on the scanner so the inventory application can successfully call ClaimDevice().
Setting DeviceEnable to TRUE will make the device ready for input. If it's a barcode scanner, it would turn on the laser. Only an enabled device will fire DataEvent()s. You would generally set the barcode scanner to true when you are ready to accept barcodes, then set it to false if the barcode was in error and you wanted them to stop scanning.
Technically, you don't have to set DeviceEnable to false prior to calling ReleaseDevice(); and you don't even have to call ReleaseDevice() prior to calling Close(). OPOS is like a neurotic maid, and will clean those up even if the application doesn't. However, I personally think it's evidence of sloppy programming if devices aren't managed properly.
Technically, it's
Open()
/ClaimDevice()
/DeviceEnabled
= TRUE /DeviceEnabled
= FALSE /ReleaseDevice()
/Close()
.Open()
requests a handle to the named device, and should work if the device exists.Close()
is the matching pair function, and it should be called when the device is no longer needed by the application.ClaimDevice()
(previously known as theClaim()
method) will attempt to access the device. If the device is an exclusive-use device (such as a barcode scanner),ClaimDevice()
will fail if a different process has already claimed it.ReleaseDevice()
(also known asRelease()
but it's name conflicted with the COM methodRelease()
) is the matching pair function that should be called when the application no longer needs to access the device. This enables graceful sharing of devices between applications. An example might be if you have a button on your sales application to enter the inventory application - the sales application should callReleaseDevice()
on the scanner so the inventory application can successfully callClaimDevice()
.Setting
DeviceEnable
to TRUE will make the device ready for input. If it's a barcode scanner, it would turn on the laser. Only an enabled device will fireDataEvent()
s. You would generally set the barcode scanner to true when you are ready to accept barcodes, then set it to false if the barcode was in error and you wanted them to stop scanning.Technically, you don't have to set
DeviceEnable
to false prior to callingReleaseDevice()
; and you don't even have to callReleaseDevice()
prior to callingClose()
. OPOS is like a neurotic maid, and will clean those up even if the application doesn't. However, I personally think it's evidence of sloppy programming if devices aren't managed properly.