Advertisement
rikokurniawan

Dial Up Timer Komponen Coding

Dec 5th, 2012
1,626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 3.09 KB | None | 0 0
  1. procedure TF_Dial.T1Timer(Sender: TObject);
  2. begin
  3. if sCheckBox1.Checked=True then begin
  4.   winexec(PAnsiCHar('rasdial '+sMemo1.text),SW_HIDE);
  5.   sLabel5.Caption:='Ditunggu GAN!! IPnya';
  6.   Sleep(3000);
  7.   //start winsock
  8.   wVersionRequested := MAKEWORD(1, 1);
  9.   WSAStartup(wVersionRequested, wsaData);
  10.  
  11.   //get computer name
  12.   GetHostName(@stri, 128);
  13.   phe := GetHostByName(@stri);
  14.  
  15.   //get ip address
  16.   pc := iNet_ntoa(PInAddr(phe^.h_addr_list^)^);
  17.   //get Hostname
  18.   //sEdit2.Text := phe^.h_Name;
  19.   //IP Localhost tidak akan ditampilkan
  20.   IF pc = '127.0.0.1' then Application.ProcessMessages
  21.   else IF pc <> '127.0.0.1' then Begin
  22.     sListBox1.Items.Add(IntToStr(sListBox1.Count + 1) + ') ' + pc);
  23.   end; //end else if pc
  24.  
  25.   //10.142
  26.   //IP Match maka Online
  27.   if sRadioButton1.Checked = True then begin
  28.     if LeftStr(pc,6) = PAnsiCHar(sMemo2.Text) Then Begin
  29.       T1.Enabled:=False;
  30.       T2.Enabled:=False;
  31.       IF pc = '127.0.0.1' then Application.ProcessMessages
  32.       else IF pc <> '127.0.0.1' then sLabel5.Caption:=LeftStr(pc,6)+' MATCH';
  33.       sButton2.Enabled:=False;
  34.     End //end if
  35.     Else if LeftStr(pc,6) <> PAnsiCHar(sMemo2.Text) Then Begin
  36.       T1.Enabled:=False;
  37.       T2.Enabled:=True;
  38.       IF pc = '127.0.0.1' then Application.ProcessMessages
  39.       else IF pc <> '127.0.0.1' then sLabel5.Caption:=LeftStr(pc,6)+' NO MATCH';
  40.       sButton2.Enabled:=True;
  41.     End;//end else
  42.   end//end if .
  43.   //182.2
  44.   else if sRadioButton2.Checked = True then begin
  45.     if LeftStr(pc,5) = PAnsiCHar(sMemo2.Text) Then Begin
  46.       T1.Enabled:=False;
  47.       T2.Enabled:=False;
  48.       IF pc = '127.0.0.1' then Application.ProcessMessages
  49.       else IF pc <> '127.0.0.1' then sLabel5.Caption:=LeftStr(pc,5)+' MATCH';
  50.       sButton2.Enabled:=False;
  51.     End //end if
  52.     Else if LeftStr(pc,5) <> PAnsiCHar(sMemo2.Text) Then Begin
  53.       T1.Enabled:=False;
  54.       T2.Enabled:=True;
  55.       IF pc = '127.0.0.1' then Application.ProcessMessages
  56.       else IF pc <> '127.0.0.1' then sLabel5.Caption:=LeftStr(pc,5)+' NO MATCH';
  57.       sButton2.Enabled:=True;
  58.     End;//end else
  59.   end;//end else 182.2
  60. end
  61. else if sCheckBox1.Checked=False then begin
  62.   winexec(PAnsiCHar('rasdial '+sMemo1.text),SW_HIDE);
  63.   Sleep(3000);
  64.   //start winsock
  65.   wVersionRequested := MAKEWORD(1, 1);
  66.   WSAStartup(wVersionRequested, wsaData);
  67.  
  68.   //get computer name
  69.   GetHostName(@stri, 128);
  70.   phe := GetHostByName(@stri);
  71.  
  72.   //get ip address
  73.   pc := iNet_ntoa(PInAddr(phe^.h_addr_list^)^);
  74.   //get Hostname
  75.   //sEdit2.Text := phe^.h_Name;
  76.   //IP Localhost tidak akan ditampilkan
  77.   IF pc = '127.0.0.1' then Application.ProcessMessages
  78.   else IF pc <> '127.0.0.1' then Begin
  79.     sListBox1.Items.Add(IntToStr(sListBox1.Count + 1) + ') ' + pc);
  80.   end; //end else if pc
  81.  
  82.   sLabel5.Caption:=pc;
  83.   //clean up winsock
  84.   WSACleanup;
  85.   T1.Enabled:=False;
  86.   T2.Enabled:=False;
  87.   sButton2.Enabled:=False;
  88. end;//end else
  89. end;
  90.  
  91. procedure TF_Dial.T2Timer(Sender: TObject);
  92. begin
  93.   winexec(PAnsiCHar('rasdial '+sMemo1.text+' /d'),SW_HIDE);
  94.   //winexec('rasphone ',SW_HIDE);
  95.   T2.Enabled:=False;
  96.   T1.Enabled:=True;
  97. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement