Re: COnvert C coding to VB
You can't directly access protected memory in a Windows app like you could in old DOS apps.
To see what I mean, create a new form with a TextBox and use this code.
VB Code:
Option Explicit
Private Declare Sub CopyMemory Lib "KERNEL32" _
Alias "RtlMoveMemory" (hpvDest As Any, _
hpvSource As Any, _
ByVal cbCopy As Long)
Private Sub Form_Load()
Dim ptraddr As Long
Dim address As Long
Dim i As Integer
ptraddr = &H408&
For i = 0 To 2
CopyMemory address, ByVal ptraddr, 4
If address = 0 Then
Text1.Text = Text1.Text & _
"No port found for LPT" & (i + 1) & vbCrLf
Else
Text1.Text = Text1.Text & _
"Address assigned to LPT" & (i + 1) & _
" is " & address & vbCrLf
End If
ptraddr = ptraddr + 4
Next i
End Sub
Set a breakpoint at the For statement so that you get a chance to see the error message, otherwise the IDE just gets blown away when the first CopyMemory executes.
You may be able to find an API to access the printer ports.
Re: COnvert C coding to VB