Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Delphi 7 Indy Komponent
#13
(24-02-2022, Saat: 23:05)mrmarman Adlı Kullanıcıdan Alıntı: Üstadım verdiğniz kod Delphi 7 de direkt calısıyor
ufak bı sıkıntı var..

Aynı anda USD ve EUR almak istiyorum... veya GBP ve 1-2 tane daha var 
StringGrid de nasıl gosterebılırız .. ?
Şimdiden sagolasın






Size bir kolaylık. 

* Indy kullanmadan SSL desteği : ( örnekte dolar kuru okunur ve ekrana mesaj olarak gösterilir )
* Parse örnek için el yordamıyla yapıldı. XML node name/value olarak okumak daha sağlıklı olur.


Uses WinInet;

function GetUrlSource( aUrl : String; aStream: TStringStream ): Boolean;
var
  hService      : HINTERNET;
  hSession      : HINTERNET;
  lpBuffer      : array[0..1023] of Byte;
  dwBytesRead   : DWORD;
  dwBytesAvail  : DWORD;
  dwTimeOut     : DWORD;
  Sessionname   : String;
begin
  Result        := False;
  if NOT Assigned(aStream) then exit;

  Sessionname   := 'TCMB_Session_' + DateTimeToStr(now);
  hSession      := InternetOpen( PChar(Sessionname), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0 );
  if not Assigned(hSession) then Exit;
  try
    hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, INTERNET_FLAG_RELOAD, 0);
    if hService = nil then
      Exit;
    try
      dwTimeOut := 60000; // a minute
      InternetSetOption(hService, INTERNET_OPTION_RECEIVE_TIMEOUT, @dwTimeOut, SizeOf(dwTimeOut));
      if InternetQueryDataAvailable(hService, dwBytesAvail, 0, 0) then
        while ( InternetReadFile(hService, @lpBuffer[0], SizeOf(lpBuffer), dwBytesRead) )
          and ( dwBytesRead <> 0 )
            do aStream.WriteBuffer(lpBuffer[0], dwBytesRead);

      aStream.Position := 0; // ready to use
      Result := aStream.Size > 0;
    finally
      InternetCloseHandle(hService);
    end;
  finally
    InternetCloseHandle(hSession);
  end;
end;


Kullanımı :

procedure TForm1.Button1Click(Sender: TObject);
Const
  LUrl = 'https://www.tcmb.gov.tr/kurlar/today.xml';
var
  LContent  : String;
  LSS       : TStringStream;
  LSrc,
  LBanknoteBuying,
  LBanknoteSelling : String;
begin
  LSS := TStringStream.Create('');
  try
    GetUrlSource( LUrl, LSS );
    LContent := LSS.DataString;
    LSrc := 'CurrencyCode="USD">';
    if Pos(LSrc, LContent) > 0 then
    begin
      Delete(LContent, 1, Pos(LSrc, LContent) + Length(LSrc)-1);
      LContent := Copy( LContent, 1, Pos('</Currency>', LContent)-1);

      LSrc := '<BanknoteBuying>';
      if Pos(LSrc, LContent) > 0 then
      begin
        Delete(LContent, 1, Pos(LSrc, LContent) + Length(LSrc)-1);
        LBanknoteBuying := Copy(LContent, 1, Pos('<', LContent)-1 );
      end;

      LSrc := '<BanknoteSelling>';
      if Pos(LSrc, LContent) > 0 then
      begin
        Delete(LContent, 1, Pos(LSrc, LContent) + Length(LSrc)-1);
        LBanknoteSelling := Copy(LContent, 1, Pos('<', LContent)-1 );
      end;
      ShowmessageFmt('USD Alış : %s  Satış : %s', [ LBanknoteBuying, LBanknoteSelling ]);
    end;
  finally
    FreeAndNil(LSS);
  end;
end;

Cevapla


Bu Konudaki Yorumlar
Delphi 7 Indy Komponent - Yazar: SKC3948 - 24-02-2022, Saat: 09:35
Delphi 7 Indy Komponent - Yazar: engerex - 24-02-2022, Saat: 19:24
Delphi 7 Indy Komponent - Yazar: SKC3948 - 24-02-2022, Saat: 19:44
Delphi 7 Indy Komponent - Yazar: mrmarman - 24-02-2022, Saat: 23:05
Cvp: Delphi 7 Indy Komponent - Yazar: maydin60 - 22-12-2023, Saat: 20:36
Delphi 7 Indy Komponent - Yazar: SKC3948 - 25-02-2022, Saat: 14:26
Delphi 7 Indy Komponent - Yazar: mrmarman - 25-02-2022, Saat: 16:27
Delphi 7 Indy Komponent - Yazar: SKC3948 - 25-02-2022, Saat: 16:48
Delphi 7 Indy Komponent - Yazar: masteryoda - 26-02-2022, Saat: 02:15
Delphi 7 Indy Komponent - Yazar: SKC3948 - 02-03-2022, Saat: 20:55
Delphi 7 Indy Komponent - Yazar: SKC3948 - 02-03-2022, Saat: 22:16
Delphi 7 Indy Komponent - Yazar: SKC3948 - 03-03-2022, Saat: 12:24
Cvp: Delphi 7 Indy Komponent - Yazar: muratcelik64 - 02-12-2023, Saat: 15:37

Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  yapay zeka delphi kl007 9 627 26-02-2026, Saat: 09:12
Son Yorum: mrmarman
  Win 11 ve Delphi 7 Minimize sorunu. enigma 7 499 11-02-2026, Saat: 10:27
Son Yorum: RAD Coder
Question Delphi formunu nasıl otomatik tam ekran yapabilirim ? erdemklt0 2 325 23-01-2026, Saat: 10:02
Son Yorum: csunguray
  Delphi SLL kullanım sorunu Bay_Y 12 1.317 22-12-2025, Saat: 18:11
Son Yorum: Bay_Y
  Delphi ile SQL server bağlantı hatası yakalama Under 20 1.987 21-11-2025, Saat: 15:24
Son Yorum: mrmarman



Konuyu Okuyanlar: 1 Ziyaretçi