You have probaly
noticed that if you go into the the
system properties then you can load the
port settings for the LPT and CoM ports.
You can display these properties dialog
boxes by using the ConfigurePort API. For
more information you can subscribe to my
Visual basic journal which will explain
this in much more detail.
Start a new standard-EXE
project and and add a Command button to
form1 and type the following code into
the code window of form1:
Private
Declare Function ConfigurePort _
Lib "winspool.drv" Alias
"ConfigurePortA" _
(ByVal pName As String, ByVal hwnd As
Long, _
ByVal pPortName As String) As Long
Private Sub Command1_Click()
MsgBox ConfigurePort("",
Me.hwnd, "COM4")
MsgBox ConfigurePort("",
Me.hwnd, "LPT1")
End Sub
Run the project
(F5) and click on the command button the
properties for the COM$ and LPT1 ports
will be displayed as well as a message
box that will display 1 ofr success and 0
if an error has occured.
|