| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- unit ProviderUnit;
- {
- This unit keeps the 'Options'-Form data like provider-servers,
- passwords for accessing the account and so on.
- ***** Attention ***** it is more than worth mentioning, that the
- passwords are visible and storead as clear text in this demo!
- Change this before you make a commercial product out of this!!!!
- (c)2005
- Jörg Meier (Bob)
- [email protected]
- }
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls, Buttons, Mask;
- type
- TProviderForm = class(TForm)
- GroupBox1: TGroupBox;
- Panel1: TPanel;
- LanChk: TCheckBox;
- PhoneList: TComboBox;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- Label1: TLabel;
- Label2: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- lbAccount: TLabel;
- lbPassword: TLabel;
- Label11: TLabel;
- Label12: TLabel;
- ConnLabel: TLabel;
- Pop3Name: TEdit;
- Pop3Port: TEdit;
- Pop3Accnt: TEdit;
- Pop3PWD: TEdit;
- SMTPName: TEdit;
- SMTPPort: TEdit;
- SMTPAccnt: TEdit;
- SMTPPwd: TEdit;
- SMTPLogin: TCheckBox;
- DelMail: TCheckBox;
- CheckMailTime: TEdit;
- Label3: TLabel;
- Label4: TLabel;
- procedure LanChkClick(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- private
- { Private-Deklarationen }
- public
- { Public-Deklarationen }
- Function GetProviderList:tStringList;
- Procedure LoadValues;
- Procedure SaveValues;
- end;
- var
- ProviderForm: TProviderForm;
- implementation
- Uses RAS, IniFiles;
- {$R *.DFM}
- function TProviderForm.GetProviderList: tStringList;
- Var I : Integer;
- Sz : Integer;
- ASz : Integer;
- Bf : PArrayRasEntryName;
- Nr : Integer;
- R : Integer;
- begin
- Result := tStringList.Create;
- Result.Sorted := True;
- Result.Duplicates := dupIgnore;
- Nr := 0;
- Sz := SizeOf(TRasEntryName);
- GetMem(Bf,Sz);
- Bf^[0].dwSize := Sz;
- ASz := Sz;
- R := RasEnumEntries(nil,nil,Bf,ASz,NR);
- if (R <> 0) and (ASz > 0) then begin
- FreeMem(Bf,Sz);
- GetMem(Bf,ASz);
- Bf^[0].dwSize := Sz;
- RasEnumEntries(nil,nil,Bf,ASz,NR);
- end;
- {$R-}
- For I := 0 to Nr-1 do begin
- Result.Add(String(Bf^[I].SzEntryName));
- end;
- {$R+}
- freemem(Bf,ASz);
- end;
- procedure TProviderForm.LanChkClick(Sender: TObject);
- begin
- PhoneList.Enabled := Not LANChk.Checked;
- ConnLabel.Enabled := Not LANChk.Checked;
- end;
- procedure TProviderForm.FormShow(Sender: TObject);
- Var Sl : tStringList;
- begin
- // Fill Combobox with Providers
- Sl := GetProviderList;
- PhoneList.Items.Assign(Sl);
- SL.Free;
- LoadValues;
- end;
- procedure TProviderForm.LoadValues;
- Var Ini : tIniFile;
- Fn : String;
- begin
- Fn := ChangeFileExt(Application.ExeName,'.INI');
- Ini := tIniFile.Create(Fn);
- Try
- LanChk.Checked := Ini.ReadBool('Connection','LanChk',True);
- PhoneList.Text := Ini.ReadString('Connection','PhoneList','');
- DelMail.Checked := Ini.ReadBool('Pop3','DelMail',True);
- Pop3Name.Text := Ini.ReadString('Pop3','Pop3Name','pop3.gmx.us');
- Pop3Port.Text := Ini.ReadString('Pop3','Pop3Port','110');
- Pop3Accnt.Text := Ini.ReadString('Pop3','Pop3Accnt','[email protected]');
- Pop3PWd.Text := Ini.ReadString('Pop3','Pop3PWd','Top Secret');
- SMTPLogin.Checked := Ini.ReadBool('SMTP','SMTPLogin',True);
- SMTPName.Text := Ini.ReadString('SMTP','SMTPName','smtp.gmx.us');
- SMTPPort.Text := Ini.ReadString('SMTP','SMTPPort','25');
- SMTPAccnt.Text := Ini.ReadString('SMTP','SMTPAccnt','[email protected]');
- SMTPPWd.Text := Ini.ReadString('SMTP','SMTPPWd','Top Secret');
- CheckMailTime.Text := Ini.ReadString('Mailer','CheckMailTime','10');
- finally
- Ini.Free;
- End;
- end;
- procedure TProviderForm.SaveValues;
- Var Ini : tIniFile;
- Fn : String;
- begin
- Fn := ChangeFileExt(Application.ExeName,'.INI');
- Ini := tIniFile.Create(Fn);
- Ini.WriteBool('Connection','LanChk',LanChk.Checked);
- Ini.WriteString('Connection','PhoneList',PhoneList.Text);
- Ini.WriteString('Pop3','Pop3Name',Pop3Name.Text);
- try
- Ini.WriteInteger('Pop3','Pop3Port',StrToInt(Pop3Port.Text));
- except
- Ini.WriteInteger('Pop3','Pop3Port',110);
- end;
- Ini.WriteString('Pop3','Pop3Accnt',Pop3Accnt.Text);
- Ini.WriteString('Pop3','Pop3PWd',Pop3PWd.Text);
- Ini.WriteBool('Pop3','DelMail',DelMail.Checked);
- Ini.WriteBool('SMTP','SMTPLogin',SMTPLogin.Checked);
- Ini.WriteString('SMTP','SMTPName',SMTPName.Text);
- try
- Ini.WriteInteger('SMTP','SMTPPort',StrToInt(SMTPPort.Text));
- except
- Ini.WriteInteger('SMTP','SMTPPort',25);
- end;
- Ini.WriteString('SMTP','SMTPAccnt',SMTPAccnt.Text);
- Ini.WriteString('SMTP','SMTPPWd',SMTPPWd.Text);
- Try
- Ini.WriteInteger('Mailer','CheckMailTime',StrToInt(CheckMailTime.Text));
- Except
- Ini.WriteInteger('Mailer','CheckMailTime',10);
- end;
- Ini.Free;
- end;
- procedure TProviderForm.FormCreate(Sender: TObject);
- begin
- LoadValues;
- end;
- procedure TProviderForm.BitBtn1Click(Sender: TObject);
- begin
- SaveValues;
- end;
- end.
|