想要一个VB 6 的串口控件,但不是MSComm,谢谢

解决方案 »

  1.   

    那就使用API了
     听说API也可以达到一样的目的,我帮你顶,等待高手
      

  2.   

    有这么好用的mscomm控件你不用,唉!
      

  3.   

    区别当然有了,否则我是傻呀,放着MSComm不用?
      

  4.   

    用API啊
    CreateFile就能打开串口
    ReadFile、WriteFile读写数据
    最后别忘了CloseHandle
    MSDN上的一个例子:
    Configuring a Communications Resource
    The following example opens a handle to COM2 and fills in a DCB structure with the current configuration. The DCB structure is then modified and used to reconfigure the device.#include <windows.h>
    #include <stdio.h>int main(int argc, char *argv[])
    {
       DCB dcb;
       HANDLE hCom;
       BOOL fSuccess;
       char *pcCommPort = "COM2";   hCom = CreateFile( pcCommPort,
                        GENERIC_READ | GENERIC_WRITE,
                        0,    // must be opened with exclusive-access
                        NULL, // no security attributes
                        OPEN_EXISTING, // must use OPEN_EXISTING
                        0,    // not overlapped I/O
                        NULL  // hTemplate must be NULL for comm devices
                        );   if (hCom == INVALID_HANDLE_VALUE) 
       {
           // Handle the error.
           printf ("CreateFile failed with error %d.\n", GetLastError());
           return (1);
       }   // Build on the current configuration, and skip setting the size
       // of the input and output buffers with SetupComm.   fSuccess = GetCommState(hCom, &dcb);   if (!fSuccess) 
       {
          // Handle the error.
          printf ("GetCommState failed with error %d.\n", GetLastError());
          return (2);
       }   // Fill in DCB: 57,600 bps, 8 data bits, no parity, and 1 stop bit.   dcb.BaudRate = CBR_57600;     // set the baud rate
       dcb.ByteSize = 8;             // data size, xmit, and rcv
       dcb.Parity = NOPARITY;        // no parity bit
       dcb.StopBits = ONESTOPBIT;    // one stop bit   fSuccess = SetCommState(hCom, &dcb);   if (!fSuccess) 
       {
          // Handle the error.
          printf ("SetCommState failed with error %d.\n", GetLastError());
          return (3);
       }   printf ("Serial port %s successfully reconfigured.\n", pcCommPort);
       return (0);
    }
      

  5.   

    你自己可以去看MSDN,很详细的
    串行通信相关函数说明:Communications Functions
    The following functions are used with communications resources.Function Description 
    BuildCommDCB Fills a specified DCB structure with values specified in a device-control string. 
    BuildCommDCBAndTimeouts Translates a device-definition string into appropriate device-control block codes and places them into a device control block. 
    ClearCommBreak Restores character transmission for a specified communications device and places the transmission line in a nonbreak state. 
    ClearCommError Retrieves information about a communications error and reports the current status of a communications device. 
    CommConfigDialog Displays a driver-supplied configuration dialog box. 
    EscapeCommFunction Directs a specified communications device to perform an extended function. 
    GetCommConfig Retrieves the current configuration of a communications device. 
    GetCommMask Retrieves the value of the event mask for a specified communications device. 
    GetCommModemStatus Retrieves modem control-register values. 
    GetCommProperties Retrieves information about the communications properties for a specified communications device. 
    GetCommState Retrieves the current control settings for a specified communications device. 
    GetCommTimeouts Retrieves the time-out parameters for all read and write operations on a specified communications device. 
    GetDefaultCommConfig Retrieves the default configuration for the specified communications device. 
    PurgeComm Discards all characters from the output or input buffer of a specified communications resource. 
    SetCommBreak Suspends character transmission for a specified communications device and places the transmission line in a break state. 
    SetCommConfig Sets the current configuration of a communications device. 
    SetCommMask Specifies a set of events to be monitored for a communications device. 
    SetCommState Configures a communications device according to the specifications in a device-control block. 
    SetCommTimeouts Sets the time-out parameters for all read and write operations on a specified communications device. 
    SetDefaultCommConfig Sets the default configuration for a communications device. 
    SetupComm Initializes the communications parameters for a specified communications device. 
    TransmitCommChar Transmits a specified character ahead of any pending data in the output buffer of the specified communications device. 
    WaitCommEvent Waits for an event to occur for a specified communications device.