怎么样在windows2000下枚举出本地机的拨号连接?有源码最好

解决方案 »

  1.   

    获取当前系统中可用的拨号连接名称.。在建立了拨号连接后,WIN9X将拨号连接的名称和属性写了注册表中,我们可以从注册表中可用的拨号连接名称及InterNet Explorer中的默认连接名称。在注册表的HKEY_USERS.DEFAULT下,列出了已经在拨号网络中建立的拨号连接的名称及其属性设置,其中各项目的名称即为可用的拨号连接的名称;各项目的值即为各连接的属性设置.如果在InterNet Explorer 中设置了默认连接名称(Internet 选项=>>连接=>>设置=>>使用以下拨号网络连接)则在注册表的HKEY_USERS.Default下,有一个字符串类型的键值,键值名InternetProfile,其值即为Internet Explorer中设置的默认连接名称.{在Uses中增加Registry单元,用于操作注册表}procedure TForm1.button3click(Sender:TObject);varregistrytemp:TRegistry;stringtemp:TStringlist;intindex:integer;beginregistrytemp:=TRegistry.Create;stringTemp:=Tstringlist.Create;with registryTemp DOBEGINRootKey:=HKEY_USERS; //根键置为HKEY_USERS//如果存在于子键.Defaultif OpenKey('.Default',false) thengetValueNames(stringsTemp); //读出各项目的名称,即拨号连接名称closekey;end;memo1.lines.add( '************当前系统中有'+IntTostr(stringsTemp.count)'+'各可用的拨号连接如下******');for intindex:=0 to stringsTemp.count-1 domemo1.lines.add(stringstemp.strings[intindex]); //列出Internet explorer中默认连接名称.if registrytemp.Openkey('.Default',false') thenmome1.lines.add('Internet explorer中默认连接名称为'+Registry.readstring('InternetProfile'));//释放内存RegistryTemp.free;StringsTemp.free;end;
      

  2.   

    大哥是win2000,和win9x不一样的
    win2000下注册表里没有的
    晕~~
      

  3.   

    { These are from lmcons.h }  DNLEN = 15; // Maximum domain name length
      UNLEN = 256; // Maximum user name length
      PWLEN = 256; // Maximum password length
      NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)  RAS_MaxDeviceType = 16;
      RAS_MaxPhoneNumber = 128;
      RAS_MaxIpAddress = 15;
      RAS_MaxIpxAddress = 21;{$IFDEF WINVER31}
    {Version 3.x sizes }
      RAS_MaxEntryName = 20;
      RAS_MaxDeviceName = 32;
      RAS_MaxCallbackNumber = 48;
    {$ELSE}
    {Version 4.x sizes }
      RAS_MaxEntryName = 256;
      RAS_MaxDeviceName = 128;
      RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
    {$ENDIF}  RAS_MaxAreaCode = 10;
      RAS_MaxPadType = 32;
      RAS_MaxX25Address = 200;
      RAS_MaxFacilities = 200;
      RAS_MaxUserData = 200;type  LPHRasConn = ^THRasConn;
      THRasConn = Longint;
    {* Identifies an active RAS connection.  (See RasEnumConnections)
    *}
      LPRasConnW = ^TRasConnW;
      TRasConnW = record
        dwSize: Longint;
        hrasconn: THRasConn;
        szEntryName: array[0..RAS_MaxEntryName] of WideChar;
    {$IFNDEF WINVER31}
        szDeviceType: array[0..RAS_MaxDeviceType] of WideChar;
        szDeviceName: array[0..RAS_MaxDeviceName] of WideChar;
    {$ENDIF}
    {$IFDEF WINVER41}
        szPhonebook: array[0..MAX_PATH - 1] of WideChar;
        dwSubEntry: Longint;
    {$ENDIF}
      end;  LPRasConnA = ^TRasConnA;
      TRasConnA = record
        dwSize: Longint;
        hrasconn: THRasConn;
        szEntryName: array[0..RAS_MaxEntryName] of AnsiChar;
    {$IFNDEF WINVER31}
        szDeviceType: array[0..RAS_MaxDeviceType] of AnsiChar;
        szDeviceName: array[0..RAS_MaxDeviceName] of AnsiChar;
    {$ENDIF}
    {$IFDEF WINVER41}
        szPhonebook: array[0..MAX_PATH - 1] of AnsiChar;
        dwSubEntry: Longint;
    {$ENDIF}
      end;  LPRasConn = ^TRasConn;
      TRasConn = TRasConnA;
    const{* Enumerates intermediate states to a connection.  (See RasDial)
    *}
      RASCS_PAUSED = $1000;
      RASCS_DONE = $2000;type  LPRasConnState = ^TRasConnState;
      TRasConnState = Integer;const  RASCS_OpenPort = 0;
      RASCS_PortOpened = 1;
      RASCS_ConnectDevice = 2;
      RASCS_DeviceConnected = 3;
      RASCS_AllDevicesConnected = 4;
      RASCS_Authenticate = 5;
      RASCS_AuthNotify = 6;
      RASCS_AuthRetry = 7;
      RASCS_AuthCallback = 8;
      RASCS_AuthChangePassword = 9;
      RASCS_AuthProject = 10;
      RASCS_AuthLinkSpeed = 11;
      RASCS_AuthAck = 12;
      RASCS_ReAuthenticate = 13;
      RASCS_Authenticated = 14;
      RASCS_PrepareForCallback = 15;
      RASCS_WaitForModemReset = 16;
      RASCS_WaitForCallback = 17;
      RASCS_Projected = 18;
    {$IFNDEF WINVER31}
      RASCS_StartAuthentication = 19;
      RASCS_CallbackComplete = 20;
      RASCS_LogonNetwork = 21;
    {$ENDIF}  RASCS_Interactive = RASCS_PAUSED;
      RASCS_RetryAuthentication = RASCS_PAUSED + 1;
      RASCS_CallbackSetByCaller = RASCS_PAUSED + 2;
      RASCS_PasswordExpired = RASCS_PAUSED + 3;  RASCS_Connected = RASCS_DONE;
      RASCS_Disconnected = RASCS_DONE + 1;type{* Describes the status of a RAS connection.  (See RasConnectionStatus)
    *}
      LPRasConnStatusW = ^TRasConnStatusW;
      TRasConnStatusW = record
        dwSize: Longint;
        rasconnstate: TRasConnState;
        dwError: LongInt;
        szDeviceType: array[0..RAS_MaxDeviceType] of WideChar;
        szDeviceName: array[0..RAS_MaxDeviceName] of WideChar;
    {$IFDEF WINVER41}
        swPhoneNumber: array[0..RAS_MaxPhoneNumber] of WideChar;
    {$ENDIF}
      end;  LPRasConnStatusA = ^TRasConnStatusA;
      TRasConnStatusA = record
        dwSize: Longint;
        rasconnstate: TRasConnState;
        dwError: LongInt;
        szDeviceType: array[0..RAS_MaxDeviceType] of AnsiChar;
        szDeviceName: array[0..RAS_MaxDeviceName] of AnsiChar;
    {$IFDEF WINVER41}
        swPhoneNumber: array[0..RAS_MaxPhoneNumber] of AnsiChar;
    {$ENDIF}
      end;  LPRasConnStatus = ^TRasConnStatus;
      TRasConnStatus = TRasConnStatusA;
    {* Describes connection establishment parameters.  (See RasDial)
    *}
      LPRasDialParamsW = ^TRasDialParamsW;
      TRasDialParamsW = record
        dwSize: LongInt;
        szEntryName: array[0..RAS_MaxEntryName] of WideChar;
        szPhoneNumber: array[0..RAS_MaxPhoneNumber] of WideChar;
        szCallbackNumber: array[0..RAS_MaxCallbackNumber] of WideChar;
        szUserName: array[0..UNLEN] of WideChar;
        szPassword: array[0..PWLEN] of WideChar;
        szDomain: array[0..DNLEN] of WideChar;
    {$IFDEF WINVER41}
        dwSubEntry: Longint;
        dwCallbackId: Longint;
    {$ENDIF}
      end;
      

  4.   

    LPRasDialParamsA = ^TRasDialParamsA;
      TRasDialParamsA = record
        dwSize: LongInt;
        szEntryName: array[0..RAS_MaxEntryName] of AnsiChar;
        szPhoneNumber: array[0..RAS_MaxPhoneNumber] of AnsiChar;
        szCallbackNumber: array[0..RAS_MaxCallbackNumber] of AnsiChar;
        szUserName: array[0..UNLEN] of AnsiChar;
        szPassword: array[0..PWLEN] of AnsiChar;
        szDomain: array[0..DNLEN] of AnsiChar;
    {$IFDEF WINVER41}
        dwSubEntry: Longint;
        dwCallbackId: Longint;
    {$ENDIF}
      end;  LPRasDialParams = ^TRasDialParams;
      TRasDialParams = TRasDialParamsA;
    {* Describes extended connection establishment options.  (See RasDial)
    *}
      LPRasDialExtensions = ^TRasDialExtensions;
      TRasDialExtensions = record
        dwSize: LongInt;
        dwfOptions: LongInt;
        hwndParent: HWND;
        reserved: LongInt;
      end;const{* 'dwfOptions' bit flags.
    *}
      RDEOPT_UsePrefixSuffix = $00000001;
      RDEOPT_PausedStates = $00000002;
      RDEOPT_IgnoreModemSpeaker = $00000004;
      RDEOPT_SetModemSpeaker = $00000008;
      RDEOPT_IgnoreSoftwareCompression = $00000010;
      RDEOPT_SetSoftwareCompression = $00000020;
      RDEOPT_DisableConnectedUI = $00000040;
      RDEOPT_DisableReconnectUI = $00000080;
      RDEOPT_DisableReconnect = $00000100;
      RDEOPT_NoUser = $00000200;
      RDEOPT_PauseOnScript = $00000400;
    type{* Describes an enumerated RAS phone book entry name.  (See RasEntryEnum)
    *}
      LPRasEntryNameW = ^TRasEntryNameW;
      TRasEntryNameW = record
        dwSize: Longint;
        szEntryName: array[0..RAS_MaxEntryName] of WideChar;
      end;  LPRasEntryNameA = ^TRasEntryNameA;
      TRasEntryNameA = record
        dwSize: Longint;
        szEntryName: array[0..RAS_MaxEntryName] of AnsiChar;
      end;  LPRasEntryName = ^TRasEntryName;
      TRasEntryName = TRasEntryNameA;
    {* Protocol code to projection data structure mapping.
    *}
      LPRasProjection = ^TRasProjection;
      TRasProjection = Integer;const  RASP_Amb = $10000;
      RASP_PppNbf = $803F;
      RASP_PppIpx = $802B;
      RASP_PppIp = $8021;
      RASP_PppLcp = $C021;
      RASP_Slip = $20000;
    type{* Describes the result of a RAS AMB (Authentication Message Block)
    ** projection.  This protocol is used with NT 3.1 and OS/2 1.3 downlevel
    ** RAS servers.
    *}
      LPRasAmbW = ^TRasAmbW;
      TRasAmbW = record
        dwSize: Longint;
        dwError: Longint;
        szNetBiosError: array[0..NETBIOS_NAME_LEN] of WideChar;
        bLana: Byte;
      end;  LPRasAmbA = ^TRasAmbA;
      TRasAmbA = record
        dwSize: Longint;
        dwError: Longint;
        szNetBiosError: array[0..NETBIOS_NAME_LEN] of AnsiChar;
        bLana: Byte;
      end;  LPRasAmb = ^TRasAmb;
      TRasAmb = TRasAmbA;
    {* Describes the result of a PPP NBF (NetBEUI) projection.
    *}
      LPRasPppNbfW = ^TRasPppNbfW;
      TRasPppNbfW = record
        dwSize: Longint;
        dwError: Longint;
        dwNetBiosError: Longint;
        szNetBiosError: array[0..NETBIOS_NAME_LEN] of WideChar;
        szWorkstationName: array[0..NETBIOS_NAME_LEN] of WideChar;
        bLana: Byte;
      end;  LPRasPppNbfA = ^TRasPppNbfA;
      TRasPppNbfA = record
        dwSize: Longint;
        dwError: Longint;
        dwNetBiosError: Longint;
        szNetBiosError: array[0..NETBIOS_NAME_LEN] of AnsiChar;
        szWorkstationName: array[0..NETBIOS_NAME_LEN] of AnsiChar;
        bLana: Byte;
      end;  LpRaspppNbf = ^TRasPppNbf;
      TRasPppNbf = TRasPppNbfA;
    {* Describes the results of a PPP IPX (Internetwork Packet Exchange)
    ** projection.
    *}
      LPRasPppIpxW = ^TRasPppIpxW;
      TRasPppIpxW = record
        dwSize: Longint;
        dwError: Longint;
        szIpxAddress: array[0..RAS_MaxIpxAddress] of WideChar;
      end;  LPRasPppIpxA = ^TRasPppIpxA;
      TRasPppIpxA = record
        dwSize: Longint;
        dwError: Longint;
        szIpxAddress: array[0..RAS_MaxIpxAddress] of AnsiChar;
      end;  LPRasPppIpx = ^TRasPppIpx;
      TRasPppIpx = TRasPppIpxA;
    {* Describes the results of a PPP IP (Internet) projection.
    *}
      LPRasPppIpW = ^TRasPppIpW;
      TRasPppIpW = record
        dwSize: Longint;
        dwError: Longint;
        szIpAddress: array[0..RAS_MaxIpAddress] of WideChar;
      

  5.   

    LPRasPppIpA = ^TRasPppIpA;
      TRasPppIpA = record
        dwSize: Longint;
        dwError: Longint;
        szIpAddress: array[0..RAS_MaxIpAddress] of AnsiChar;{$IFNDEF WINNT35COMPATIBLE}    {* See RASPPPIPW comment.
        *}
        szServerIpAddress: array[0..RAS_MaxIpAddress] of AnsiChar;{$ENDIF}
      end;  LPRasPppIp = ^TRasPppIp;
      TRasPppIp = TRasPppIpA;
    {* Describes the results of a PPP LCP/multi-link negotiation.
    *}
      LpRasPppLcp = ^TRasPppLcp;
      TRasPppLcp = record
        dwSize: Longint;
        fBundled: LongBool;
      end;
    {* Describes the results of a SLIP (Serial Line IP) projection.
    *}
      LpRasSlipW = ^TRasSlipW;
      TRasSlipW = record
        dwSize: Longint;
        dwError: Longint;
        szIpAddress: array[0..RAS_MaxIpAddress] of WideChar;
      end;  LpRasSlipA = ^TRasSlipA;
      TRasSlipA = record
        dwSize: Longint;
        dwError: Longint;
        szIpAddress: array[0..RAS_MaxIpAddress] of AnsiChar;
      end;  LpRasSlip = ^TRasSlip;
      TRasSlip = TRasSlipA;
    const{* If using RasDial message notifications, get the notification message code
    ** by passing this string to the RegisterWindowMessageA() API.
    ** WM_RASDIALEVENT is used only if a unique message cannot be registered.
    *}
      RASDIALEVENT = 'RasDialEvent';
      WM_RASDIALEVENT = $CCCD;
    {* Prototypes for caller's RasDial callback handler.  Arguments are the
    ** message ID (currently always WM_RASDIALEVENT), the current RASCONNSTATE and
    ** the error that has occurred (or 0 if none).  Extended arguments are the
    ** handle of the RAS connection and an extended error code.
    **
    ** For RASDIALFUNC2, subsequent callback notifications for all
    ** subentries can be cancelled by returning FALSE.
    *}
    {
    typedef VOID (WINAPI *RASDIALFUNC)( UINT, RASCONNSTATE, DWORD );
    typedef VOID (WINAPI *RASDIALFUNC1)( HRASCONN, UINT, RASCONNSTATE, DWORD, DWORD );
    typedef DWORD (WINAPI *RASDIALFUNC2)( DWORD, DWORD, HRASCONN, UINT, RASCONNSTATE, DWORD, DWORD );For Delphi: Just define the callback as:procedure RASCallback(msg: Integer; state: TRasConnState;
        dwError: Longint); stdcall;procedure RASCallback1(hConn: THRasConn; msg: Integer;
        state: TRasConnState; dwError: Longint; dwEexterror: Longint); stdcall;procedure RASCallback2(dwCallbackId, dwSubEntry: Longint; hConn: THRasConn;
        msg: Integer; state: TRasConnState; dwError: Longint;
        dwEexterror: Longint); stdcall;
    }type{* Information describing a RAS-capable device.
    *}
      LPRasDevInfoA = ^TRasDevInfoA;
      TRasDevInfoA = record
        dwSize: Longint;
        szDeviceType: array[0..RAS_MaxDeviceType] of AnsiChar;
        szDeviceName: array[0..RAS_MaxDeviceName] of AnsiChar;
      end;  LPRasDevInfoW = ^TRasDevInfoW;
      TRasDevInfoW = record
        dwSize: Longint;
        szDeviceType: array[0..RAS_MaxDeviceType] of WideChar;
        szDeviceName: array[0..RAS_MaxDeviceName] of WideChar;
      end;  LPRasDevInfo = ^TRasDevInfo;
      TRasDevInfo = TRasDevInfoA;
    (* RAS Country Information (currently retreieved from TAPI).
    *)
      LPRasCtryInfo = ^TRasCtryInfo;
      TRasCtryInfo = record
        dwSize,
          dwCountryID,
          dwNextCountryID,
          dwCountryCode,
          dwCountryNameOffset: Longint;
      end;