begin process at 2012 02 11 16:27:05
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Réseau & Internet

 > ACTIVER/DÉSACTIVER LE PROXY

ACTIVER/DÉSACTIVER LE PROXY


 Information sur la source

Note :
Aucune note
Catégorie :Réseau & Internet Niveau :Débutant Date de création :12/01/2004 Vu / téléchargé :9 161 / 491

Auteur : Phenix40

Ecrire un message privé
Site perso
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Ce petit code permet la lecture et la modification de l'état du proxy, en passant par la base de registre.

Source

  • unit ProxyOneOff;
  • interface
  • uses
  • Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  • Dialogs, StdCtrls, Registry, ShellApi;
  • type
  • TForm1 = class(TForm)
  • GroupBox1: TGroupBox;
  • CheckBox1: TCheckBox;
  • HttpE: TEdit;
  • ProxyOverrideEdit: TEdit;
  • Label1: TLabel;
  • Label2: TLabel;
  • Label3: TLabel;
  • Label4: TLabel;
  • FtpE: TEdit;
  • SecuriseE: TEdit;
  • GopherE: TEdit;
  • SocksE: TEdit;
  • Label6: TLabel;
  • Label7: TLabel;
  • Label8: TLabel;
  • Label9: TLabel;
  • procedure CheckBox1Click(Sender: TObject);
  • procedure FormCreate(Sender: TObject);
  • procedure Label3MouseEnter(Sender: TObject);
  • procedure Label3MouseLeave(Sender: TObject);
  • procedure Label3Click(Sender: TObject);
  • procedure Label4Click(Sender: TObject);
  • private
  • { Private declarations }
  • public
  • { Public declarations }
  • procedure DetectProxy;
  • procedure EnableProxy(Enable : Boolean);
  • end;
  • var
  • Form1: TForm1;
  • Proxy: boolean;
  • ProxyOverride: String;
  • ProxyServer: String;
  • Actif : integer;
  • Protocoles : String;
  • Http, Ftp, Securise, Gopher, Socks : String;
  • implementation
  • {$R *.dfm}
  • procedure TForm1.CheckBox1Click(Sender: TObject);
  • begin
  • if CheckBox1.Checked then
  • begin
  • EnableProxy(True);
  • CheckBox1.Caption :='Désactiver le proxy';
  • end
  • else
  • begin
  • EnableProxy(False);
  • CheckBox1.Caption :='Activer le proxy';
  • end;
  • end;
  • procedure TForm1.DetectProxy;
  • var Reg : TRegistry;
  • Pos1, Pos2 : integer;
  • Car : Char;
  • begin
  • Reg := tRegistry.Create;
  • Reg.RootKey := HKEY_CURRENT_USER;
  • Reg.OpenKey('\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',True);
  • ProxyServer:= Reg.ReadString('ProxyServer');
  • ProxyOverrideEdit.Text := Reg.ReadString('ProxyOverride');
  • Protocoles := Reg.ReadString('ProxyServer');
  • Actif := Reg.ReadInteger('ProxyEnable');
  • if Actif = 0 then
  • begin
  • CheckBox1.Checked := False;
  • end
  • else
  • begin
  • CheckBox1.Checked := True;
  • end;
  • Reg.CloseKey;
  • Reg.Free;
  • // Série de booooooooooocle idiôte ;)
  • //***** Http
  • Pos1 := Pos('=', ProxyServer)+1;
  • Pos2 := Pos(';', ProxyServer);
  • Http:=Copy(ProxyServer,Pos1,Pos2-Pos1);
  • HttpE.Text:= Http;
  • Delete(ProxyServer, 1,Pos2);
  • //***** FTP
  • Pos1 := Pos('=', ProxyServer)+1;
  • Pos2 := Pos(';', ProxyServer);
  • Ftp:=Copy(ProxyServer,Pos1,Pos2-Pos1);
  • FtpE.Text := Ftp;
  • Delete(ProxyServer, 1,Pos2);
  • //***** Sécurisé
  • Pos1 := Pos('=', ProxyServer)+1;
  • Pos2 := Pos(';', ProxyServer);
  • Securise:=Copy(ProxyServer,Pos1,Pos2-Pos1);
  • SecuriseE.Text:=Securise;
  • Delete(ProxyServer, 1,Pos2);
  • //***** Gopher
  • Pos1 := Pos('=', ProxyServer)+1;
  • Pos2 := Pos(';', ProxyServer);
  • Gopher:=Copy(ProxyServer,Pos1,Pos2-Pos1);
  • GopherE.Text := Gopher;
  • Delete(ProxyServer, 1,Pos2);
  • //***** Socks
  • Pos1 := Pos('=', ProxyServer)+1;
  • Pos2 := Pos(';', ProxyServer);
  • Socks:=Copy(ProxyServer,Pos1,Length(ProxyServer));
  • SocksE.Text:= Socks;
  • end;
  • procedure TForm1.EnableProxy(Enable: Boolean);
  • var
  • reg : TRegistry;
  • begin
  • Reg := TRegistry.Create;
  • Reg.RootKey := HKEY_CURRENT_USER;
  • Reg.OpenKey('\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',True);
  • if Enable then
  • Reg.WriteInteger('ProxyEnable',1)
  • else
  • Reg.WriteInteger('ProxyEnable',0);
  • Reg.CloseKey;
  • Reg.Free;
  • end;
  • procedure TForm1.FormCreate(Sender: TObject);
  • begin
  • DetectProxy;
  • CheckBox1.Checked := Actif =1;
  • end;
  • procedure TForm1.Label3MouseEnter(Sender: TObject);
  • begin
  • TLabel(Sender).Font.Color := ClBlue;
  • end;
  • procedure TForm1.Label3MouseLeave(Sender: TObject);
  • begin
  • TLabel(Sender).Font.Color := ClBlack;
  • end;
  • procedure TForm1.Label3Click(Sender: TObject);
  • begin
  • ShellExecute(Handle, 'OPEN', 'http://www.phenixcreations.com','','',SW_SHOWNORMAL);
  • end;
  • procedure TForm1.Label4Click(Sender: TObject);
  • begin
  • ShellExecute(Handle, 'OPEN', 'mailto:farid.ferhati@phenixcreations.com','','',SW_SHOWNORMAL);
  • end;
  • end.
unit ProxyOneOff;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Registry, ShellApi;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    HttpE: TEdit;
    ProxyOverrideEdit: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    FtpE: TEdit;
    SecuriseE: TEdit;
    GopherE: TEdit;
    SocksE: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    procedure CheckBox1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Label3MouseEnter(Sender: TObject);
    procedure Label3MouseLeave(Sender: TObject);
    procedure Label3Click(Sender: TObject);
    procedure Label4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure DetectProxy;
    procedure EnableProxy(Enable : Boolean);
  end;

var
  Form1: TForm1;
  Proxy: boolean;
  ProxyOverride: String;
  ProxyServer: String;
  Actif : integer;
  Protocoles : String;
  Http, Ftp, Securise, Gopher, Socks : String;
implementation

{$R *.dfm}

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
 if CheckBox1.Checked then
 begin
  EnableProxy(True);
  CheckBox1.Caption :='Désactiver le proxy';
 end
 else
  begin
  EnableProxy(False);
  CheckBox1.Caption :='Activer le proxy';
 end;
end;

procedure TForm1.DetectProxy;
var Reg : TRegistry;
    Pos1, Pos2 : integer;
    Car : Char;
begin
 Reg := tRegistry.Create;
 Reg.RootKey := HKEY_CURRENT_USER;
 Reg.OpenKey('\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',True);
 ProxyServer:= Reg.ReadString('ProxyServer');
 ProxyOverrideEdit.Text := Reg.ReadString('ProxyOverride');
 Protocoles := Reg.ReadString('ProxyServer');
 Actif := Reg.ReadInteger('ProxyEnable');
 if Actif = 0 then
 begin
  CheckBox1.Checked := False;
 end
 else
 begin
   CheckBox1.Checked := True;
 end;

 Reg.CloseKey;
 Reg.Free;
// Série de booooooooooocle idiôte ;) 
//***** Http
Pos1 := Pos('=', ProxyServer)+1;
Pos2 := Pos(';', ProxyServer);
Http:=Copy(ProxyServer,Pos1,Pos2-Pos1);
HttpE.Text:= Http;
Delete(ProxyServer, 1,Pos2);
//***** FTP
Pos1 := Pos('=', ProxyServer)+1;
Pos2 := Pos(';', ProxyServer);
Ftp:=Copy(ProxyServer,Pos1,Pos2-Pos1);
FtpE.Text := Ftp;
Delete(ProxyServer, 1,Pos2);
//***** Sécurisé
Pos1 := Pos('=', ProxyServer)+1;
Pos2 := Pos(';', ProxyServer);
Securise:=Copy(ProxyServer,Pos1,Pos2-Pos1);
SecuriseE.Text:=Securise;
Delete(ProxyServer, 1,Pos2);
//***** Gopher
Pos1 := Pos('=', ProxyServer)+1;
Pos2 := Pos(';', ProxyServer);
Gopher:=Copy(ProxyServer,Pos1,Pos2-Pos1);
GopherE.Text := Gopher;
Delete(ProxyServer, 1,Pos2);
//***** Socks
Pos1 := Pos('=', ProxyServer)+1;
Pos2 := Pos(';', ProxyServer);
Socks:=Copy(ProxyServer,Pos1,Length(ProxyServer));
SocksE.Text:= Socks;
end;

procedure TForm1.EnableProxy(Enable: Boolean);
var
 reg : TRegistry;
begin
 Reg := TRegistry.Create;
 Reg.RootKey := HKEY_CURRENT_USER;
 Reg.OpenKey('\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',True);
 if Enable then
  Reg.WriteInteger('ProxyEnable',1)
 else
  Reg.WriteInteger('ProxyEnable',0);
  
 Reg.CloseKey;
 Reg.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 DetectProxy;
  CheckBox1.Checked := Actif =1;
end;

procedure TForm1.Label3MouseEnter(Sender: TObject);
begin
 TLabel(Sender).Font.Color := ClBlue;
end;

procedure TForm1.Label3MouseLeave(Sender: TObject);
begin
 TLabel(Sender).Font.Color := ClBlack;
end;

procedure TForm1.Label3Click(Sender: TObject);
begin
 ShellExecute(Handle, 'OPEN', 'http://www.phenixcreations.com','','',SW_SHOWNORMAL);
end;

procedure TForm1.Label4Click(Sender: TObject);
begin
 ShellExecute(Handle, 'OPEN', 'mailto:farid.ferhati@phenixcreations.com','','',SW_SHOWNORMAL);
end;

end.


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources de la même categorie

Source avec Zip Source avec une capture PETITE APPLICATION DE TCHAT DANS UN RÉSEAU LOCALE par benimen
Source avec Zip Source avec une capture LOG DE PING POUR SURVEILLER LA QUALITÉ D'UNE CONNECTION par PhilLU
Source avec Zip GET IP AVEC INDY par Gerard
Source avec Zip GCS-FACEBOOK par pinkfloydhighopes
Source avec Zip Source avec une capture PINGNOW ADRESSE IP par mekhmoukhs

Commentaires et avis

Commentaire de costello le 15/01/2004 21:28:38

1) ce code marche vraiment ?
2) comment tu l'as testé ?
3) as tu des exemples d'utilisations concrètes de ce code ?

je me demande, enfin, je crois que ce code pourrait m'être utile, sans en être tout à fait sûr.

Commentaire de StanleyJopson le 30/07/2004 11:25:04

Good ...

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,452 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales