Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write directly to COM1 in Windows 2000

Status
Not open for further replies.

Gigatech

Programmer
Jul 12, 2000
80
CR
Hi,
I'm a Delphi 6 user. Do you know how to write directly to COM1 (to open a cash drawer) in Windows 2000 or NT ?

Thanks
 
//---------------------------------------------------------------------------
void __fastcall TForm1::OpenTray()
{
//Kasse auf Knopfdruck öffnen
unsigned long res=0;
unsigned int i =0;
HANDLE com=CreateFile("COM1",GENERIC_WRITE,0,NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,0);
if (com>0)
{
WriteFile(com,"XXXXXXXXXXXXXXXXXXXX",20,&res,NULL);
CloseHandle(com);
}
}

Hier ist ein CBuilder-Beispiel.

Gruß, SamC
 
If you dont want any 'C' in your Delphi program (who would?)
you can find lots of (FREE) third party components that give you access to the COMM ports. Browse for Delphi Components.

I use one Called 'CPORT Lib' which works well with the operating systems you want to use.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top