我的程序在如果安装了moden的驱动程序,就无法打开串口
因为好象被驱动程序占用了,而且如果直接对moden通过AT指令的话
兼容性也不太好,那位做过用程序控制moden的,给个方法
最好有代码,因为我没有头绪

解决方案 »

  1.   

    拨号上网的程序网上多的是,你上 www.playicq.com下一个
      

  2.   

    你给的论坛里面没有sreach功能啊
      

  3.   


    五、获取当前活动的连接及其连接状态
      1、获取当前活动的连接
        获取当前活动的连接的RasAPI函数为RasEnumConnections,其函数原型为:
    function RasEnumConnections( var lprasconn : RASCONN ;//接收活动连接的缓冲区的指针
    var lpcb: DWORD;//缓冲区大小
    var lpcConnections : DWORD//实际的活动连接数
    ) : DWORD; stdcall;
    function RasEnumConnections;external RasApiDll name 'RasEnumConnectionsA';
    参数lprasconn提供了一个RASCONN类型数组的指针,指向一个接收活动连接的缓冲
      区,其中RASCONN的类型说明如下:
    RASCONN = record
    dwSize : DWORD;//该结构所占内存的大小(Bytes),一般设置为SizeOf(RASCONN)
    hrasconn : HRASCONN;//活动连接的句柄
    szEntryName : array[0..RAS_MaxEntryName] of char;//活动连接的名称
    szDeviceType : array[0..RAS_MaxDeviceType] of char;//活动连接的所用的设备类型
    szDeviceName : array[0..RAS_MaxDeviceName] of char;//活动连接的所用的设备名称
    end;
        参数lpcb为缓冲区大小(Bytes).
        参数lpcConnections将返回实际的连接数目.    函数返回值为0表示执行成功;否则为错误代码.  2、获取指定连接的连接状态
        获取指定连接的连接状态的RasAPI函数为RasGetConnectStatus,其函数原型为:
    function RasGetConnectStatus(
    hrasconn : HRASCONN; //指定活动连接的句柄
    lprasconnstatus : LPRASCONNSTATUS//连接状态参数
    ) : DWORD; stdcall;
    function RasGetConnectStatus;external RasApiDll name 'RasGetConnectStatusA';
        连接状态参数lprasconnstatus是一个RASCONNSTATUS类型的指针,将返回连接状态参数.
      RASCONNSTATUS和LPRASCONNSTATUS的类型说明如下:
    LPRASCONNSTATUS = ^RASCONNSTATUS;
    RASCONNSTATUS = record
    dwSize : DWORD;//该结构所占内存的大小(Bytes),一般设置为SizeOf(RASCONNSTATUS)
    rasconnstate : RASCONNSTATE;//连接状态标识,一组DWORD类型数值的集合。
    dwError : DWORD;//错误类型标识符
    szDeviceType : array[0..RAS_MaxDeviceType] of char;//活动连接的所用的设备类型
    szDeviceName : array[0..RAS_MaxDeviceName] of char;//活动连接的所用的设备名称
    end;
        函数返回值为0表示执行成功;否则为错误代码.    下面是一个应用例子,列出了当前系统中活动的连接的名称及其连接状态.
    注意,应在RASCONN缓冲区的第一个RASCONN结构中设置dwSize.const
    MaxConnections = 10;//最多的拨号连接数目
    var
    connections : array[0..MaxConnections-1] of RASCONN;
    longSize : dword;
    intAvailabelConnections : dword;
    intIndex : integer;
    dwResult : DWORD;
    strTemp : string;
    RASCONNSTATUSData : RASCONNSTATUS; 
    begin
    connections[ 0 ].dwSize := sizeof(RASCONN);//结构的大小
    longSize := MaxConnections * connections[ 0 ].dwSize;//缓冲区大小
    intAvailabelConnections := 0;//实际的活动连接的数目
    //获取当前系统中活动的连接
    dwResult := RasEnumConnections( connections[ 0 ], longSize,intAvailabelConnections );
    if dwResult < >  0 then //获取当前系统中活动的连接
    memo1.lines.add( '获取当前系统中活动的连接:' + GetRasError( dwResult ))
    else
    begin
    memo1.lines.add( '当前系统中活动的连接' + inttostr( intAvailabelConnections ) 
    + '个,列举如下' );
    for intIndex := 0 to intAvailabelConnections - 1 do
    begin
    strTemp := '连接名称:' + StrPAS( connections[ intIndex ].szEntryName )
    + ' 设备类型:' + StrPAS( connections[ intIndex ].szDeviceType )
    + ' 设备名称:' + StrPAS( connections[ intIndex ].szDeviceName );
    //获取连接状态
    dwResult := RasGetConnectStatus( connections[ intIndex ].hRasConn,@RASCONNSTATUSData );
    if 0 < >  dwResult then
    strTemp := strTemp + ' 连接状态未知:' + GetRasError( dwResult )
    else if RASCONNSTATUSData.rasconnstate = RASCS_Connected then
    strTemp := strTemp + ' 连接状态:已连接'
    else
    strTemp := strTemp + ' 连接状态:(' + 
    inttostr(RASCONNSTATUSData.rasconnstate)+')';
    memo1.lines.add( strTemp );
    end;
    end;
    end;以上程序在PWIN98+Delphi3.0下调试通过。