Close the device, Methods of accessing the device, Obtaining access to the device – MagTek 99875125 User Manual
Page 14

MagTek Device Driver for Windows
prompted to swipe a card by using the
display
command, followed by a
read
command to
instruct the device to return the card data when swiped. All the facilities of the driver are utilized
during this stage of operation.
Close the device
When the application is finished with the device, it simply closes the port using the handle
obtained when it opened it. The driver shuts down the device if required.
METHODS OF ACCESSING THE DEVICE
This section describes how to use control language commands in a Visual Basic development
environment using the MSComm (Microsoft Communication) component.
Obtaining access to the device
If the MSComm (Microsoft Communication) ActiveX component is used to access the device,
set the
CommPort
property to the com port number of the device. Then, set the
PortOpen
property to
True
to open it. The following example shows how:
‘set error handling
On Error Resume Next
‘open the port
Comm.CommPort = 5
Comm.PortOpen = True
If Err.Number <> 0 Then
<
End If
on error goto 0
Note
After issuing an Open command, the computer may spend several
seconds attempting to communicate with the device. During this
time the computer will appear to be hung up.
If file I/O access is desired, you have the option of using either the device’s friendly name, such
as
\\.\micr+
(where
\\.\
specifies to Windows that this is a device and not a file) or its port
name,
COM<5..15>
. The friendly name is more intuitive and easier to remember than a port
number; however, the serial method gives the programmer better control of the device. The port
number can be found in the operating system’s device UI. For example, open Control
Panel/System/Device Manager/MagTek and select a specific driver. Under Properties, select the
Settings tab. This gives both the Friendly Name and the port name (
COM<5-15>
). It also
identifies the physical port that will be used to communicate with the device.
Open the device using either of the previous names. Use whatever facility is provided by your
development environment for opening files. For Visual Basic, do the following:
6