⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exnew0.~pas

📁 一卡通离线积分系统
💻 ~PAS
字号:
unit exnew0;
{
TMagRas New Entry Example
=========================

Create a new entry in the RAS phonebook (ie a new connection).
It shows the minimal options required for a new entry, which
will be created with TCP/IP, PPP and dynamic IP addresses

Created by Angus Robertson, Magenta Systems Ltd, England
in 2000, delphi@magsys.co.uk, http://www.magsys.co.uk/delphi/
Last updated: 30th April 2001

To load this example, the TMagRas components need to have been previously
installed on the component palette.

}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls, magrascon, magrasapi, magrasedt, ComCtrls,
  KsControls, KsButtons, KsSkinButtons, KsHooks, KsForms, KsSkinForms;

type
  TDialFrom = class(TForm)
    MagRasCon: TMagRasCon;
    ConnList: TListBox;
    Label3: TLabel;
    MagRasEdt: TMagRasEdt;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    entEntryName: TEdit;
    Label2: TLabel;
    entDeviceName: TComboBox;
    Label43: TLabel;
    entUserName: TEdit;
    Label45: TLabel;
    entPassword: TEdit;
    entUseCountryandAreaCodes: TCheckBox;
    Label6: TLabel;
    entCountryName: TComboBox;
    Label44: TLabel;
    entCountryCode: TEdit;
    Label11: TLabel;
    entAreaCode: TEdit;
    Label13: TLabel;
    entLocalNumber: TEdit;
    Status: TStatusBar;
    SeSkinForm1: TSeSkinForm;
    doClear: TSeSkinButton;
    doCreate: TSeSkinButton;
    doExit: TSeSkinButton;
    procedure doExitClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure doClearClick(Sender: TObject);
    procedure doCreateClick(Sender: TObject);
    procedure entCountryNameChange(Sender: TObject);
    procedure entUseCountryandAreaCodesClick(Sender: TObject);
    procedure SeSkinButton1Click(Sender: TObject);
  private
    { Private declarations }
	procedure RefreshConnList ;
	procedure GetDialProps ;
  public
    { Public declarations }
  end;

var
  DialFrom: TDialFrom;
  DialProps: TDialProps;        // dialling properties
  DialLocation: TDialLocation;  // default dialling location
  DialCard: TDialCard ;		 	// default dialling calling card
  DialCountry: TDialCountry ;	// default country dialling info

implementation

{$R *.DFM}
uses UMain;
procedure TDialFrom.doExitClick(Sender: TObject);
begin
    DialFrom.Free ;
end;

procedure TDialFrom.RefreshConnList ;
begin
    // get list of phonebook entries
	MagRasCon.GetPhoneBookEntries ;
//  MagRasCon.PhoneBookEntries.Sort ;  4.60 already sorted
	ConnList.Items.Assign (MagRasCon.PhoneBookEntries) ;	 // display it
end ;

procedure TDialFrom.GetDialProps ;
begin
    MagRasCon.GetTransCaps (DialProps, DialLocation, DialCard, DialCountry) ;
end ;

procedure TDialFrom.FormCreate(Sender: TObject);
var
	I: integer ;
begin
// see if RAS has been installed
	if MagRasCon.TestRAS then
    begin
     // get list of phonebook entries
	    RefreshConnList ;

	// get list of RAS capable modems and devices - don't sort list
    	MagRasCon.GetDeviceList ;
        if MagRasCon.DeviceNameList.Count <> 0 then
        begin
        	for I := 0 to MagRasCon.DeviceNameList.Count - 1 do
            begin
            	entDeviceName.Items.Add (MagRasCon.DeviceNameList [I] +
	                ' (' + LowerCase (MagRasCon.DeviceTypeList [I]) + ')') ;
			end ;
            entDeviceName.ItemIndex := 0 ;  // set first
		end ;

   	// get CountryList, CountryIds and CountryCodes - don't sort list!
    	MagRasEdt.GetAllCountryInfo ;
        entCountryName.Items.Assign (MagRasEdt.CountryList) ;

	// get dialling properties, location, calling card, etc
		GetDialProps ;                                     
		doClearClick (self) ;
	end
    else
    begin
	 	Status.SimpleText := 'RAS is not installed' ;
        beep ;
    end ;
end;

procedure TDialFrom.doClearClick(Sender: TObject);
var
	I: integer ;
begin
    entEntryName.Text := '' ;
    entUserName.Text := '' ;
    entPassword.Text := '' ;

// DialLocation hold the current location dialling properties
    entUseCountryandAreaCodes.Checked := true ;
    entCountryCode.Text := IntToStr (DialLocation.CountryCode) ;
    entAreaCode.Text := DialLocation.CityCode ;
    entLocalNumber.Text := '' ;

// find country name from country Id
	if MagRasEdt.CountryList.Count = 0 then exit ;
	for I := 0 to Pred (MagRasEdt.CountryList.Count) do
    begin
        if DialLocation.CountryID = cardinal (MagRasEdt.CountryIds [I]) then
        begin
	        entCountryName.ItemIndex := I ;
            break ;
		end ;
	end ;
end;

procedure TDialFrom.entCountryNameChange(Sender: TObject);
begin
    entCountryCode.Text := IntToStr
    				(MagRasEdt.CountryCodes [entCountryName.ItemIndex]) ;
end;

procedure TDialFrom.entUseCountryandAreaCodesClick(Sender: TObject);
begin
   	entCountryName.Enabled := entUseCountryAndAreaCodes.Checked ;
   	entCountryCode.Enabled := entUseCountryAndAreaCodes.Checked ;
   	entAreaCode.Enabled := entUseCountryAndAreaCodes.Checked ;
end;

procedure TDialFrom.doCreateClick(Sender: TObject);



var
	errcode: integer ;
    newname: string ;
begin
	newname := trim (entEntryName.Text) ;
   	if MagRasCon.ValidateName (newname) <> 0 then
   	begin
       	Status.SimpleText := MagRasCon.StatusStr ;
       	beep ;
       	exit ;
   	end ;

// default all properties for a PPP TCP/IP entry
	MagRasEdt.PPPDefault ;

// set specific properties
	with MagRasEdt do
    begin
	// telephone numbers - required
    // CountryId and CountryCode must not be zero if following is checked
		bUseCountryAndAreaCodes := entUseCountryAndAreaCodes.Checked ;
        if entCountryName.ItemIndex >= 0 then
			        CountryId := CountryIds [entCountryName.ItemIndex] ;
        try
			CountryCode := StrToInt (entCountryCode.Text) ;
		except
        	CountryCode := 1 ;
		end ;
		AreaCode := entAreaCode.Text ;
		LocalPhoneNumber := entLocalNumber.Text ;

	// dial params - optional
      	UserName := entUserName.Text ;
    	Password := entPassword.Text ;

	// device stuff - required, must match precisely name and type from lists
    	DeviceName := MagRasCon.DeviceNameList [entDeviceName.ItemIndex] ;
    	DeviceType := MagRasCon.DeviceTypeList [entDeviceName.ItemIndex] ;
	end ;
    errcode := MagRasEdt.PutAllEntryProps (newname) ;
    if errcode = 0 then MagRasEdt.PutDialProps (newname) ;
    if errcode <> 0 then
    begin
		Status.SimpleText := MagRasEdt.StatusStr ;
        beep ;
    end
	else
    begin
		Status.SimpleText := 'Created New Entry OK' ;
        beep ;
    end ;
	RefreshConnList ;
end;

procedure TDialFrom.SeSkinButton1Click(Sender: TObject);
var
	I: integer ;
begin
    entEntryName.Text := '' ;
    entUserName.Text := '' ;
    entPassword.Text := '' ;

// DialLocation hold the current location dialling properties
    entUseCountryandAreaCodes.Checked := true ;
    entCountryCode.Text := IntToStr (DialLocation.CountryCode) ;
    entAreaCode.Text := DialLocation.CityCode ;
    entLocalNumber.Text := '' ;

// find country name from country Id
	if MagRasEdt.CountryList.Count = 0 then exit ;
	for I := 0 to Pred (MagRasEdt.CountryList.Count) do
    begin
        if DialLocation.CountryID = cardinal (MagRasEdt.CountryIds [I]) then
        begin
	        entCountryName.ItemIndex := I ;
            break ;
		end ;
end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -