|
-
Jan 24th, 2005, 01:59 AM
#1
Thread Starter
New Member
COnvert C coding to VB
Hello. Can anybody convert this C coding to VB? This coding is to read location to obtain addresses of my printer port. Also , i have this algorithm so that when my IR sensor is triggered, (connected to parallel port in my PC) it will also triggered my web camera to capture picture(connected to usb port) but i dont know how to write it in VB. Thanks in advance
The C coding need to convert to VB
#include <stdio.h>
#include <dos.h>
void main (void)
{
unsigned int far *ptraddr ; /*pointer to location of Port Adress*/
unsigned int address ; /* adress of port*/
int a:
ptraddr=(unsigned int far *) 0x00000408;
for (a=0;a<3;a++)
{
address = *ptraddr;
if (address ==0)
printf ("No port found for LPT5d \n, a+1);
else
printf ( "Adress assigned to PLT&d is %Xh\n", a+1, address);
*ptraddr++;
}
}
The algo needed to write in VB
Initialize base address, pin...etc
Read the parallel port
Is Bit0 = 0 /*If yes, loop again upper line and this line
/*If No, continue
Read parallel port
Is Bit0=1 /*If yes, loop again this statement
/*If no continue
Initiate code to detect camera
Make camera capture picture
End
-
Jan 24th, 2005, 11:06 AM
#2
Frenzied Member
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.
-
Jan 24th, 2005, 01:08 PM
#3
Re: COnvert C coding to VB
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|