Current location - Quotes Website - Team slogan - In vc6.0, how to realize the function of selecting serial number and how to write the code?
In vc6.0, how to realize the function of selecting serial number and how to write the code?
List all serial ports in the dialog box;

Select a serial port to obtain the corresponding address;

Operate on the address as needed.

//serial address

int? LCR、DLL、DLM、LSR、MCR、MSR、THR、RBR、IER、IIR

//Baud rate

longBaudRate

//Check mode

int? Parity;

Invalid? CMycomView::OnAppPort()?

{

//? TODO:? Supplement? Yours Command? Handler? Code? here

comport? comportDlg

comportDlg。 DoModal();

com _ port = comportDlg.com _ port

BaudRate=comportDlg。 Podrat;

Parity =comportDlg. Parity;

if(com_port== 1)

{

LCR = 0x3FB;

DLL = 0x3F8

DLM = 0x3f 9;

LSR = 0x3FD;

MCR = 0x3FC

MSR = 0x3FE;

THR = 0x3f 8;

RBR = 0x3f 8;

IER = 0x3f 9;

IIR = 0x3FA

}

if(com_port==2)

{

LCR = 0x2FB;

DLL = 0x2F8

DLM = 0x2f 9;

LSR = 0x2FD;

MCR = 0x2FC

MSR = 0x2FE;

THR = 0x2f 8;

RBR = 0x2f 8;

IER = 0x2f 9;

IIR = 0x2FA

}

}