Programlama yapalım ve Öğrenelim. - Delphi Eğitim153
  Ana Sayfa
  .NET Eğitim Notları
  Visual C# .NET Örnek Kodları
  VisualBasic.NET Örnek Kodları
  J# Örnekleri
  ASP.NET Örnek Kodları
  Delphi Eğitim
  => Delphi Eğitim1
  => Delphi Eğitim2
  => Delphi Eğitim3
  => Delphi Eğitim4
  => Delphi Eğitim5
  => Delphi Eğitim6
  => Delphi Eğitim7
  => Delphi Eğitim8
  => Delphi Eğitim9
  => Delphi Eğitim10
  => Delphi Eğitim11
  => Delphi Eğitim13
  => Delphi Eğitim14
  => Delphi Eğitim15
  => Delphi Eğitim16
  => Delphi Eğitim17
  => Delphi Eğitim18
  => Delphi Eğitim19
  => Delphi Eğitim20
  => Delphi Eğitim21
  => Delphi Eğitim22
  => Delphi Eğitim23
  => Delphi Eğitim24
  => Delphi Eğitim25
  => Delphi Eğitim26
  => Delphi Eğitim27
  => Delphi Eğitim28
  => Delphi Eğitim29
  => Delphi Eğitim30
  => Delphi Eğtim31
  => Delphi Eğitim32
  => Delphi Eğitim33
  => Delphi Eğitim34
  => Delphi Eğitim35
  => Delphi Eğitim36
  => Delphi Eğitim37
  => Delphi Eğitim38
  => Delphi Eğitim39
  => Delphi Eğitim40
  => Delphi Eğitim41
  => Delphi Eğitim42
  => Delphi Eğitim43
  => Delphi Eğitim44
  => Delphi Eğitim45
  => Delphi Eğitim46
  => Delphi Eğitim47
  => Delphi Eğitim48
  => Delphi Eğitim49
  => Delphi Eğitim50
  => Delphi Eğitim51
  => Delphi Eğitim52
  => Delphi Eğitim53
  => Delphi Eğitim54
  => Delphi Eğitim55
  => Delphi Eğitim56
  => Delphi Eğitim57
  => Delphi Eğitim58
  => Delphi Eğitim59
  => Delphi Eğitim60
  => Delphi Eğitim61
  => Delphi Eğitim62
  => Delphi Eğitim63
  => Delphi Eğitim64
  => Delphi Eğitim65
  => Delphi Eğitim66
  => Delphi Eğitim67
  => Delphi Eğitim68
  => Delphi Eğitim69
  => Delphi Eğitim70
  => Delphi Eğitim71
  => Delphi Eğitim72
  => Delphi Eğitim73
  => Delphi Eğitim74
  => Delphi Eğitim75
  => Delphi Eğitim76
  => Delphi Eğitim77
  => Delphi Eğitim78
  => Delphi Eğitim79
  => Delphi Eğitim80
  => Delphi Eğitim81
  => Delphi Eğitim82
  => Delphi Eğitim83
  => Delphi Eğitim84
  => Delphi Eğitim85
  => Delphi Eğitim86
  => Delphi Eğitim87
  => Delphi Eğitim88
  => Delphi Eğitim89
  => Delphi Eğitim90
  => Delphi Eğitim91
  => Delphi Eğitim92
  => Delphi Eğitim93
  => Delphi Eğitim94
  => Delphi Eğitim95
  => Delphi Eğitim96
  => Delphi Eğitim97
  => Delphi Eğitim98
  => Delphi Eğitim99
  => Delphi Eğitim100
  => Delphi Eğitim101
  => Delphi Eğitim102
  => Delphi Eğitim103
  => Delphi Eğitim104
  => Delphi Eğitim105
  => Delphi Eğitim106
  => Delphi Eğitim107
  => Delphi Eğitim108
  => Delphi Eğitim109
  => Delphi Eğitim110
  => Delphi Eğitim111
  => Delphi Eğitim112
  => Delphi Eğitim113
  => Delphi Eğitim114
  => Delphi Eğitim115
  => Delphi Eğitim116
  => Delphi Eğitim117
  => Delphi Eğitim118
  => Delphi Eğitim119
  => Delphi Eğitim120
  => Delphi Eğitim121
  => Delphi Eğitim122
  => Delphi Eğitim123
  => Delphi Eğitim124
  => Delphi Eğitim125
  => Delphi Eğitim126
  => Delphi Eğitim127
  => Delphi Eğitim128
  => Delphi Eğitim129
  => Delphi Eğitim130
  => Delphi Eğitim131
  => Delphi Eğitim132
  => Delphi Eğitim133
  => Delphi Eğitim134
  => Delphi Eğitim135
  => Delphi Eğitim136
  => Delphi Eğitim137
  => Delphi Eğitim138
  => Delphi Eğitim139
  => Delphi Eğitim140
  => Delphi Eğitim141
  => Delphi Eğitim142
  => Delphi Eğitim143
  => Delphi Eğitim144
  => Delphi Eğitim145
  => Delphi Eğitim146
  => Delphi eğitim147
  => Delphi Eğitim148
  => Delphi Eğitim149
  => Delphi Eğitim150
  => Delphi Eğitim151
  => Delphi Eğitim152
  => Delphi Eğitim153
  => Delphi Eğitim154
  => Delphi Eğitim155
  => Delphi Eğitim156
  => Delphi Eğitim157
  => Delphi Eğitim158
  => Delphi Eğitim159
  => Delphi Eğitim160
  => Delphi Eğitim161
  => Delphi Eğitim162
  => Delphi Eğitim164
  => Delphi Eğitim165
  => Delphi Eğitim166
  => Delphi Eğitim167
  => Delphi Eğitim168
  => Delphi Eğitim169
  => Delphi Eğitim170
  => Delphi Eğitim171
  => Delphi Eğitim172
  => Delphi Eğitim173
  => Delphi Eğitim174
  => Delphi Eğitim175
  => Delphi Eğitim176
  => Delphi Eğitim177
  => Delphi Eğitim178
  => Delphi Eğitim179
  => Delphi Eğitim180
  => Delphi Eğitim181
  => Delphi Eğitim182
  => Delphi Eğitim183
  => Delphi Eğitim184
  => Delphi Eğitim185
  => Delphi Eğitim186
  => Delphi Eğitim187
  => Delphi Eğitim188
  => Delphi Eğitim189
  => Delphi Eğitim190
  => Delphi Eğitim191
  => Delphi Eğitim192
  => Delphi Eğitim193
  => Delphi Eğitim194
  => Delphi Eğitim195
  => Delphi Eğitim196
  => Delphi Eğitim197
  => Delphi Eğitim198
  => Delphi Eğitim199
  => Delphi Eğitim200
  => Delphi Eğitim201
  => Delphi Eğitim202
  => Delphi Eğitim203
  => Delphi Eğitim204
  => Delphi Eğitim205
  => Delphi Eğitim206
  => Delphi Eğitim207
  => Delphi Eğitim208
  => Delphi Eğitim209
  => Delphi Eğitim210
  => Delphi Eğitim211
  => Delphi Eğitim212
  => Delphi Eğitim213
  => Delphi Eğitim214
  => Delphi Eğitim215
  => Delphi Eğitim216
  => Delphi Eğitim217
  => Delphi Eğitim218
  => Delphi Eğitim219
  => Delphi Eğitim220
  => Delphi Eğitim221
  => Delphi Eğitim222
  => Delphi Eğitim223
  => Delphi Eğitim224
  => Delphi Eğitim225
  => Delphi Eğitim226
  => Delphi Eğitim227
  => Delphi Eğitim228
  => Delphi Eğitim229
  => Delphi Eğitim230
  => Delphi Eğitim231
  => Delphi Eğitim232
  => Delphi Eğitim233
  => Delphi Eğitim234
  => Delphi Eğitim235
  => Delphi Eğitim236
  => Delphi Eğitim237
  => Delphi Eğitim238
  => Delphi Eğitim239
  => Delphi Eğitim240
  => Delphi Eğitim241
  => Delphi Eğitim242
  İletişim

neoturk: Forum - "md5 ile şifreleme"

var

  i: integer;

  str1, str2: string;

begin

  IdCoderMD51.Reset;

  IdCoderMD51.AutoCompleteInput := True;

  str1 := IdCoderMD51.CodeString('merhaba');

  str2 := '';

  for i := 0 to Length(str1) do

  begin

    str2 := str2 + LowerCase(IntToHex(BYTE(str1[i]), 2));

  end;

showmessage('merhaba metninin şifrelenmiş hali = '+str1+' dir.');

showmessage('ve md5 metninin hex karşılığı da = '+str2+' dir.');

end;

 

 

*************************

md5 kullanımı yöntem-2

*************************

//alıntıdır

 

unit MD5;

 

interface

 

type

  Dizi= Array of integer;

 

function MD_5(str: string): string;

 

implementation

 

function rhex(num: integer): string;

var

  str,hex_chr: string;

  j: integer;

begin

  hex_chr:='0123456789abcdef';

  str:=";

  for j:=0 to 3 do

    str:=str+hex_chr[((num shr (j*8+4)) and $F)+1]+hex_chr[((num shr (j*8)) and $F)+1];

  Result:=str;

end;

 

function str2blks_MD5(str: string): Dizi;

var

  nblk: integer;

  blks: Dizi;

  i: integer;

begin

  nblk:=((length(str)+8) shr 6)+1;

  SetLength(blks,nblk*16);

  for i:=0 to nblk*16-1 do blks[i]:=0;

  for i:=0 to length(str)-1 do

    blks[i shr 2]:=blks[i shr 2] or ((ord(str[i+1]) shl ((i mod 4)*8)));

  blks[i shr 2]:=blks[i shr 2] or ($80 shl ((i mod 4)*8));

  blks[nblk*16-2]:=length(str)*8;

  Result:=blks;

end;

 

function add(x,y: integer): integer;

var

  lsw,msw: integer;

begin

  lsw:=(x and $FFFF)+(y and $FFFF);

  msw:=(x shr 16)+(y shr 16)+(lsw shr 16);

  Result:=(msw shl 16) or (lsw and $FFFF);

end;

 

function rol(num,cnt: integer): integer;

begin

  Result:=(num shl cnt) or (num shr (32 - cnt));

end;

 

function cmn(q, a, b, x, s, t: integer): integer;

begin

  Result:= add(rol(add(add(a, q), add(x, t)), s), b);

end;

 

function ff(a, b, c, d, x, s, t: integer): integer;

Begin

  Result:= cmn((b and c) or ((not b) and d), a, b, x, s, t);

end;

 

function gg(a, b, c, d, x, s, t: integer): integer;

Begin

  Result:= cmn((b and d) or (c and (not d)), a, b, x, s, t);

end;

 

function hh(a, b, c, d, x, s, t: integer): integer;

Begin

  Result:= cmn(b xor c xor d, a, b, x, s, t);

end;

 

function ii(a, b, c, d, x, s, t: integer): integer;

Begin

  Result:= cmn(c xor (b or (not d)), a, b, x, s, t);

end;

 

function MD_5(str: string): string;

var

  x: dizi;

  a,b,c,d,olda,oldb,oldc,oldd: integer;

  i: integer;

begin

  x:= str2blks_MD5(str);

  a:= 1732584193;

  b:= -271733879;

  c:= -1732584194;

  d:= 271733878;

 

  i:=0;

  while i<length(x) do

  begin

    olda := a;

    oldb := b;

    oldc := c;

    oldd := d;

 

    a := ff(a, b, c, d, x[i+ 0], 7 , -680876936);

    d := ff(d, a, b, c, x[i+ 1], 12, -389564586);

    c := ff(c, d, a, b, x[i+ 2], 17,  606105819);

    b := ff(b, c, d, a, x[i+ 3], 22, -1044525330);

    a := ff(a, b, c, d, x[i+ 4], 7 , -176418897);

    d := ff(d, a, b, c, x[i+ 5], 12,  1200080426);

    c := ff(c, d, a, b, x[i+ 6], 17, -1473231341);

    b := ff(b, c, d, a, x[i+ 7], 22, -45705983);

    a := ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);

    d := ff(d, a, b, c, x[i+ 9], 12, -1958414417);

    c := ff(c, d, a, b, x[i+10], 17, -42063);

    b := ff(b, c, d, a, x[i+11], 22, -1990404162);

    a := ff(a, b, c, d, x[i+12], 7 ,  1804603682);

    d := ff(d, a, b, c, x[i+13], 12, -40341101);

    c := ff(c, d, a, b, x[i+14], 17, -1502002290);

    b := ff(b, c, d, a, x[i+15], 22,  1236535329);

 

    a := gg(a, b, c, d, x[i+ 1], 5 , -165796510);

    d := gg(d, a, b, c, x[i+ 6], 9 , -1069501632);

    c := gg(c, d, a, b, x[i+11], 14,  643717713);

    b := gg(b, c, d, a, x[i+ 0], 20, -373897302);

    a := gg(a, b, c, d, x[i+ 5], 5 , -701558691);

    d := gg(d, a, b, c, x[i+10], 9 ,  38016083);

    c := gg(c, d, a, b, x[i+15], 14, -660478335);

    b := gg(b, c, d, a, x[i+ 4], 20, -405537848);

    a := gg(a, b, c, d, x[i+ 9], 5 ,  568446438);

    d := gg(d, a, b, c, x[i+14], 9 , -1019803690);

    c := gg(c, d, a, b, x[i+ 3], 14, -187363961);

    b := gg(b, c, d, a, x[i+ 8], 20,  1163531501);

    a := gg(a, b, c, d, x[i+13], 5 , -1444681467);

    d := gg(d, a, b, c, x[i+ 2], 9 , -51403784);

    c := gg(c, d, a, b, x[i+ 7], 14,  1735328473);

    b := gg(b, c, d, a, x[i+12], 20, -1926607734);

 

    a := hh(a, b, c, d, x[i+ 5], 4 , -378558);

    d := hh(d, a, b, c, x[i+ 8], 11, -2022574463);

    c := hh(c, d, a, b, x[i+11], 16,  1839030562);

    b := hh(b, c, d, a, x[i+14], 23, -35309556);

    a := hh(a, b, c, d, x[i+ 1], 4 , -1530992060);

    d := hh(d, a, b, c, x[i+ 4], 11,  1272893353);

    c := hh(c, d, a, b, x[i+ 7], 16, -155497632);

    b := hh(b, c, d, a, x[i+10], 23, -1094730640);

    a := hh(a, b, c, d, x[i+13], 4 ,  681279174);

    d := hh(d, a, b, c, x[i+ 0], 11, -358537222);

    c := hh(c, d, a, b, x[i+ 3], 16, -722521979);

    b := hh(b, c, d, a, x[i+ 6], 23,  76029189);

    a := hh(a, b, c, d, x[i+ 9], 4 , -640364487);

    d := hh(d, a, b, c, x[i+12], 11, -421815835);

    c := hh(c, d, a, b, x[i+15], 16,  530742520);

    b := hh(b, c, d, a, x[i+ 2], 23, -995338651);

 

    a := ii(a, b, c, d, x[i+ 0], 6 , -198630844);

    d := ii(d, a, b, c, x[i+ 7], 10,  1126891415);

    c := ii(c, d, a, b, x[i+14], 15, -1416354905);

    b := ii(b, c, d, a, x[i+ 5], 21, -57434055);

    a := ii(a, b, c, d, x[i+12], 6 ,  1700485571);

    d := ii(d, a, b, c, x[i+ 3], 10, -1894986606);

    c := ii(c, d, a, b, x[i+10], 15, -1051523);

    b := ii(b, c, d, a, x[i+ 1], 21, -2054922799);

    a := ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);

    d := ii(d, a, b, c, x[i+15], 10, -30611744);

    c := ii(c, d, a, b, x[i+ 6], 15, -1560198380);

    b := ii(b, c, d, a, x[i+13], 21,  1309151649);

    a := ii(a, b, c, d, x[i+ 4], 6 , -145523070);

    d := ii(d, a, b, c, x[i+11], 10, -1120210379);

    c := ii(c, d, a, b, x[i+ 2], 15,  718787259);

    b := ii(b, c, d, a, x[i+ 9], 21, -343485551);

 

    a := add(a, olda);

    b := add(b, oldb);

    c := add(c, oldc);

    d := add(d, oldd);

 

    inc(i,16);

  end;

  Result:= rhex(a) + rhex(b) + rhex(c) + rhex(d);

end;

 

end.

 

 

//kullanımı

showmessage('merhaba şifrelenmiş hali ='+MD_5('merhaba'));

 

 

umarım yardımcı olmuşumdur...

 

kolay gelsin...

 

 

 

 

neoturk: Forum- "edit üzerinde rastgele sayı üreten fonksiyon"

"

cevaplarsanız sevinirim Bugün 14:26

 

bir edit üzerinde 5000 milsaniyede rastgele sayı üreten kod lar

nelerdir acaba nasıl yapabilirim

 

greenplover

"

 

 

cevap:

 

güzel bir soru...

 

aşağıdaki şekilde teorik olarak kodu yazıyorum,

muhtemelen çalışmasını bekliyorum.....

 

function rastgeleuret(uzunluk: Integer): string;

var

  str: string;

begin

  Randomize;

  str    := '0123456789';

  Result := '';

  repeat

    Result := Result + str[Random(Length(str)) + 1];

  until (Length(Result) = uzunluk)

end;

 

 

//kullanımı

procedure TForm1.Button1Click(Sender: TObject);

begin

showmessage(rastgeleuret(20));// 20 haneli sayısal şifre

end;

 

karışık harflerden şifre üretmek istiyorsan,

 

str:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

 

şeklinde değiştirebilirsin. ( türkçe karakterleri eklemedim )

 

her ikisi de olsun diyorsan,

 

str:= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

 

şeklinde değiştirebilirsin.

 

biraz daha düzenlersek:

 

function rastgeleuret(uzunluk: Integer;tur:byte): string;

var

  str: string;

begin

  Randomize;

  //tur 1 ise sadece rakamlar olsun

  //tur 2 ise sadece harfler olsun

  //tur 3 ise karışık olsun

  case tur of

  1:str:= '0123456789';

  2:str:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

  3:str:= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

  end;

  Result := '';

  repeat

    Result := Result + str[Random(Length(str)) + 1];

  until (Length(Result) = uzunluk)

end;

 

//kullanımı

procedure TForm1.Button1Click(Sender: TObject);

begin

showmessage(rastgeleuret(20,1));// 20 haneli sayısal şifre

showmessage(rastgeleuret(10,2));// 10 haneli string şifre

showmessage(rastgeleuret(30,3));// 30 haneli karışık şifre

end;

 

milisaniye ayarını da sen yaparsın artık. ( timer nesnesi ile )

 

umarım faydamız olmuştur..........

 

 

saygılarımla_

 

neoturk [ xxnt03@lycos.co.uk ]

 

Delphi - .....................................

 

neoturk: Forum- "edit üzerinde rastgele sayı üreten fonksiyon"

"

cevaplarsanız sevinirim Bugün 14:26

 

bir edit üzerinde 5000 milsaniyede rastgele sayı üreten kod lar

nelerdir acaba nasıl yapabilirim

 

greenplover

"

 

 

cevap:

 

güzel bir soru...

 

aşağıdaki şekilde teorik olarak kodu yazıyorum,

muhtemelen çalışmasını bekliyorum.....

 

function rastgeleuret(uzunluk: Integer): string;

var

  str: string;

begin

  Randomize;

  str    := '0123456789';

  Result := '';

  repeat

    Result := Result + str[Random(Length(str)) + 1];

  until (Length(Result) = uzunluk)

end;

 

 

//kullanımı

procedure TForm1.Button1Click(Sender: TObject);

begin

showmessage(rastgeleuret(20));// 20 haneli sayısal şifre

end;

 

karışık harflerden şifre üretmek istiyorsan,

 

str:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

 

şeklinde değiştirebilirsin. ( türkçe karakterleri eklemedim )

 

her ikisi de olsun diyorsan,

 

str:= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

 

şeklinde değiştirebilirsin.

 

biraz daha düzenlersek:

 

function rastgeleuret(uzunluk: Integer;tur:byte): string;

var

  str: string;

begin

  Randomize;

  //tur 1 ise sadece rakamlar olsun

  //tur 2 ise sadece harfler olsun

  //tur 3 ise karışık olsun

  case tur of

  1:str:= '0123456789';

  2:str:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

  3:str:= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

  end;

  Result := '';

  repeat

    Result := Result + str[Random(Length(str)) + 1];

  until (Length(Result) = uzunluk)

end;

 

//kullanımı

procedure TForm1.Button1Click(Sender: TObject);

begin

showmessage(rastgeleuret(20,1));// 20 haneli sayısal şifre

showmessage(rastgeleuret(10,2));// 10 haneli string şifre

showmessage(rastgeleuret(30,3));// 30 haneli karışık şifre

end;

 

milisaniye ayarını da sen yaparsın artık. ( timer nesnesi ile )

 

umarım faydamız olmuştur..........

neoturk: Forum - "internet bağlantısının olup olmadığını hangi nesne ile anlarız "

"

internetin olup olmadığının anlaşılması? Bugün 13:54

program içerisinde internetin olup olmadığının hengi nesne

ile nasıl anlarız?

kolay gelsin...

 

xmx

"

 

cevap:

 

**********************

yöntem 1:

**********************

local internet nesnelerini kullanarak var olan IP

numaranı öğrenebilirsin.

 

örneğin,

 

( form üzerine bu nesnelerden istediğin 1 tanesini yerleştir )

 

nmstrm komponentleri içinde bulunan FTP nesnesini kullanarak,

( delphi 6 )

 

showmessage('IP adresim = '+nmftp1.LocalIP);

 

indy komponentleri içinde bulunan IPwatch nesnesini kullanarak,

( delphi 6 - delphi 7 )

 

showmessage('IP adresim = '+idipwatch1.LocalIP);

 

 

**********************

yöntem 2:

**********************

kodlama ile IP numarasını veya Bağlantı metodunu öğrenebilirsin.

 

//bağlantı türünü verir

{************** get connection kind *********************}

//uses wininet

function Get_ConnectionKind(sender:Tobject;var strKind: string): Boolean;

const

  MODEM = 1;

  LAN = 2;

  PROXY = 4;

  BUSY = 8;

var

  flags: DWORD;

begin

  strKind := '';

  Result := InternetGetConnectedState(@flags, 0);

  if Result then

  begin

    if (flags and MODEM) = MODEM then strKind := 'Modem';

    if (flags and LAN) = LAN then strKind := 'LAN';

    if (flags and PROXY) = PROXY then strKind := 'Proxy';

    if (flags and BUSY) = BUSY then strKind := 'Modem Busy';

  end;

end;

{

//kullanımı

procedure TForm1.Button1Click(Sender: TObject);

var

  strKind: string;

begin

  if GetConnectionKind(strKind) then

    ShowMessage(strKind);

end;

}

 

 

//pc nin local IP sini verir

{***************** detect host ip ***********************}

//uses winsock

function DetectHostIP(sender:Tobject;var IP: string): Boolean;

var

  wsdata : TWSAData;

  hostName : array [0..255] of char;

  hostEnt : PHostEnt;

  addr : PChar;

begin

  WSAStartup ($0101, wsdata);

  try

    gethostname (hostName, sizeof (hostName));

    hostEnt := gethostbyname (hostName);

    if Assigned (hostEnt) then

      if Assigned (hostEnt^.h_addr_list) then begin

        addr := hostEnt^.h_addr_list^;

        if Assigned (addr) then begin

          IP := Format ('%d.%d.%d.%d', [byte (addr [0]),

          byte (addr [1]), byte (addr [2]), byte (addr [3])]);

          Result := True;

        end

        else

          Result := False;

      end

      else

        Result := False

    else begin

      Result := False;

    end;

  finally

    WSACleanup;

  end

end;

 

{

//kullanımı

var userip:string;

begin

detecthostip(userip);

showmessage(userip);

end;

}

 

 

benim tavsiyem, kodlama ile yapman...

 

seçim senindir...

 

bunları gereken şekilde kullanarak pc nin internete bağlı olup

olmadığını öğrenebilirsin...

 

**********************

not:

**********************

her IP numarasının olması ( 127.0.0.1 den farklı olan ),

o pc nin internete bağlı olduğu anlamına gelmez....

internete bağlı olmayan, fakat network içerisinde olan pc lerin de,

ip numaraları mevcuttur...

 

aynı zamanda, local IP sonucunda yanılgıya düşmemek için,

 

 if GetSystemMetrics(SM_NETWORK) AND $01 = $01 then

    ShowMessage('pc networke bağlıdır') else

    ShowMessage('pc networke bağlı değildir');

 

kod bloğunu da kontrol amaçlı kullanabilirsiniz...

 

sonuç olarak şöyle bir mantık elde edebiliriz,

 

if (myip<>'127.0.0.1') and (networke_bağlı_değilsen) and (bağlantı_türün_modem_ise) then

         showmessage('internete bağlıdır');

( local bir pc için ve network yok ise kesin çözüm olarak görüyorum )

 

 

if (networke_bağlı_isen) and (bağlantı_türün_modemden_farklı_ise) then

     showmessage('internete bağlıdır');

( networke bağlı olan bir pc, ana pcden dolayı internete çıkış yapabilir )

 

genel bilgi olarak:

192.168.*.* şeklindeki IP numaraları network client pc lerinde geçerlidir.

 

gereken düzenekleri kendinize göre kurgulayabilirsiniz...

 

kolay gelsin...

 

saygılarımla_

 

neoturk [ xxnt03@lycos.co.uk ]

 

Delphi - .....................................

 

neoturk: Forum - "internet bağlantısının olup olmadığını hangi nesne ile anlarız "

"

internetin olup olmadığının anlaşılması? Bugün 13:54

program içerisinde internetin olup olmadığının hengi nesne

ile nasıl anlarız?

kolay gelsin...

 

xmx

"

 

cevap:

 

**********************

yöntem 1:

**********************

local internet nesnelerini kullanarak var olan IP

numaranı öğrenebilirsin.

 

örneğin,

 

( form üzerine bu nesnelerden istediğin 1 tanesini yerleştir )

 

nmstrm komponentleri içinde bulunan FTP nesnesini kullanarak,

( delphi 6 )

 

showmessage('IP adresim = '+nmftp1.LocalIP);

 

indy komponentleri içinde bulunan IPwatch nesnesini kullanarak,

( delphi 6 - delphi 7 )

 

showmessage('IP adresim = '+idipwatch1.LocalIP);

 

 

**********************

yöntem 2:

**********************

kodlama ile IP numarasını veya Bağlantı metodunu öğrenebilirsin.

 

//bağlantı türünü verir

{************** get connection kind *********************}

//uses wininet

function Get_ConnectionKind(sender:Tobject;var strKind: string): Boolean;

const

  MODEM = 1;

  LAN = 2;

  PROXY = 4;

  BUSY = 8;

var

  flags: DWORD;

begin

  strKind := '';

  Result := InternetGetConnectedState(@flags, 0);

  if Result then

  begin

    if (flags and MODEM) = MODEM then strKind := 'Modem';

    if (flags and LAN) = LAN then strKind := 'LAN';

    if (flags and PROXY) = PROXY then strKind := 'Proxy';

    if (flags and BUSY) = BUSY then strKind := 'Modem Busy';

  end;

end;

{

//kullanımı

procedure TForm1.Button1Click(Sender: TObject);

var

  strKind: string;

begin

  if GetConnectionKind(strKind) then

    ShowMessage(strKind);

end;

}

 

 

//pc nin local IP sini verir

{***************** detect host ip ***********************}

//uses winsock

function DetectHostIP(sender:Tobject;var IP: string): Boolean;

var

  wsdata : TWSAData;

  hostName : array [0..255] of char;

  hostEnt : PHostEnt;

  addr : PChar;

begin

  WSAStartup ($0101, wsdata);

  try

    gethostname (hostName, sizeof (hostName));

    hostEnt := gethostbyname (hostName);

    if Assigned (hostEnt) then

      if Assigned (hostEnt^.h_addr_list) then begin

        addr := hostEnt^.h_addr_list^;

        if Assigned (addr) then begin

          IP := Format ('%d.%d.%d.%d', [byte (addr [0]),

          byte (addr [1]), byte (addr [2]), byte (addr [3])]);

          Result := True;

        end

        else

          Result := False;

      end

      else

        Result := False

    else begin

      Result := False;

    end;

  finally

    WSACleanup;

  end

end;

 

{

//kullanımı

var userip:string;

begin

detecthostip(userip);

showmessage(userip);

end;

}

 

 

benim tavsiyem, kodlama ile yapman...

 

seçim senindir...

 

bunları gereken şekilde kullanarak pc nin internete bağlı olup

olmadığını öğrenebilirsin...

 

**********************

not:

**********************

her IP numarasının olması ( 127.0.0.1 den farklı olan ),

o pc nin internete bağlı olduğu anlamına gelmez....

internete bağlı olmayan, fakat network içerisinde olan pc lerin de,

ip numaraları mevcuttur...

 

aynı zamanda, local IP sonucunda yanılgıya düşmemek için,

 

 if GetSystemMetrics(SM_NETWORK) AND $01 = $01 then

    ShowMessage('pc networke bağlıdır') else

    ShowMessage('pc networke bağlı değildir');

 

kod bloğunu da kontrol amaçlı kullanabilirsiniz...

 

sonuç olarak şöyle bir mantık elde edebiliriz,

 

if (myip<>'127.0.0.1') and (networke_bağlı_değilsen) and (bağlantı_türün_modem_ise) then

         showmessage('internete bağlıdır');

( local bir pc için ve network yok ise kesin çözüm olarak görüyorum )

 

 

if (networke_bağlı_isen) and (bağlantı_türün_modemden_farklı_ise) then

     showmessage('internete bağlıdır');

( networke bağlı olan bir pc, ana pcden dolayı internete çıkış yapabilir )

 

genel bilgi olarak:

192.168.*.* şeklindeki IP numaraları network client pc lerinde geçerlidir.

 

gereken düzenekleri kendinize göre kurgulayabilirsiniz...

 

kolay gelsin...

 

saygılarımla_

 

neoturk [ xxnt03@lycos.co.uk ]

 

Delphi - .....................................

Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol