[bcb 6.0]LPT1 aanspreken

Pagina: 1
Acties:

  • elgringo
  • Registratie: Januari 2001
  • Laatst online: 01-09 18:17
Ik wil data naar LPT1 onder w2k met bcb 6 sturen. Ik maak een handle aan:
code:
1
2
3
4
5
6
7
8
HANDLE lpt=NULL;
lpt = CreateFile("LPT1",
                  GENERIC_WRITE,
                  0,
                  NULL,
                  OPEN_EXISTING,
                  FILE_ATTRIBUTE_NORMAL,
                  NULL);

en weet niet hoe ik data verstuur (mbv writefile), heeft iemand hier een concret voorbeeld van? en het openen van LPT1 gaat dat goed zo?

Ik kan alleen pagina's vinden over serial communicatie, maar dat is anders en heb ik al onder de knie

if broken it is, fix it you should


  • elgringo
  • Registratie: Januari 2001
  • Laatst online: 01-09 18:17
schop

if broken it is, fix it you should


Verwijderd

Wat wil je precies aansturen via je lpt?

  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 20:49

Creepy

Tactical Espionage Splatterer

Er zijn al redelijk wat topic voorbij gekomen voor aansturing van het één en ander via de LPT poort.

En wil je simpel karaktertjes sturen via de LPT poort, of wil je echt directe aansturing?

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney


  • elgringo
  • Registratie: Januari 2001
  • Laatst online: 01-09 18:17
Op dinsdag 30 april 2002 12:32 schreef Creepy het volgende:
Er zijn al redelijk wat topic voorbij gekomen voor aansturing van het één en ander via de LPT poort.

En wil je simpel karaktertjes sturen via de LPT poort, of wil je echt directe aansturing?
Ik wil een handle van LPT1 om zo characters er naartoe sturen. met win98 had ik een proggie dat gewoon in het juiste geheugenadres wat kwakte maar dat werkt hier niet....

simpele karaktertjes dus

if broken it is, fix it you should


  • elgringo
  • Registratie: Januari 2001
  • Laatst online: 01-09 18:17
schop....

if broken it is, fix it you should


Verwijderd

met dlportio kan je ook gewoon weer naar het juiste geheugen adres karakters "kwakken"

Verwijderd

zoiets bv.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
void* _CommunicationHandle = CreateFile("LPT1", GENERIC_WRITE, 0, NULL, 
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

.
.
.

BYTE Buffer[100];
DWORD nBytesToWrite=100;
DWORD nBytesWritten;

return WriteFile(_CommunicationHandle, &Buffer, nBytesToWrite, 
&nBytesWritten, NULL);

  • elgringo
  • Registratie: Januari 2001
  • Laatst online: 01-09 18:17
en hoe vul je die buffer (met bijv 255)?
dus buffer[1]=255 (dat pikt BCB dus niet)

if broken it is, fix it you should


  • elgringo
  • Registratie: Januari 2001
  • Laatst online: 01-09 18:17
ik heb het werkend maar de data wordt pas verzonden als ik closehandle(hLPT) heb gedaan, kan dit ook voorkomen worden?

ff de code:
Form create
code:
1
2
3
4
5
6
7
   hLPT = CreateFile("LPT1",
                  GENERIC_WRITE,
                  0,
                  NULL,
                  OPEN_EXISTING,
                  FILE_ATTRIBUTE_NORMAL,
                  NULL);

Form close
code:
1
CloseHandle(hLPT);

Button 1(stuurt 0 naar lpt1 (alles uit))
code:
1
2
3
4
5
6
7
char buffer[10];
memset(buffer,0,sizeof(buffer));
char n=0;
strcpy(buffer,&n);

DWORD geschreven;
WriteFile(hLPT,buffer,1,&geschreven,NULL);

in het bovenste geval wordt de data (o) pas gestuurd als het programma is afgesloten

if broken it is, fix it you should


  • Creepy
  • Registratie: Juni 2001
  • Laatst online: 20:49

Creepy

Tactical Espionage Splatterer

Is er niet een flush of flushfile functie?

"I had a problem, I solved it with regular expressions. Now I have two problems". That's shows a lack of appreciation for regular expressions: "I know have _star_ problems" --Kevlin Henney

Pagina: 1