Subversion Repositories decoder

Rev

Rev 4 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 7
Line 2581... Line 2581...
2581
    else
2581
    else
2582
      openfile(dlg_open.FileName, '', false);
2582
      openfile(dlg_open.FileName, '', false);
2583
  end;
2583
  end;
2584
end;
2584
end;
2585
 
2585
 
2586
// http://www.delphipraxis.net/post43515.html
2586
// https://www.delphipraxis.net/post43515.html , fixed , works for Delphi 12 Athens
2587
Function GetHTML(AUrl: string): string;
2587
function GetHTML(AUrl: string): RawByteString;
2588
var
2588
var
2589
  databuffer : array[0..4095] of char;
2589
  databuffer : array[0..4095] of ansichar; // SIC! ansichar!
2590
  ResStr : string;
2590
  ResStr : ansistring; // SIC! ansistring
2591
  hSession, hfile: hInternet;
2591
  hSession, hfile: hInternet;
2592
  dwindex,dwcodelen,dwread,dwNumber: cardinal;
2592
  dwindex,dwcodelen,dwread,dwNumber: cardinal;
2593
  dwcode : array[1..20] of char;
2593
  dwcode : array[1..20] of char;
2594
  res    : pchar;
2594
  res    : pchar;
2595
  Str    : pchar;
2595
  Str    : pansichar; // SIC! pansichar
2596
begin
2596
begin
2597
  ResStr:='';
2597
  ResStr:='';
-
 
2598
  if (system.pos('http://',lowercase(AUrl))=0) and
2598
  if pos('http://',lowercase(AUrl))=0 then
2599
     (system.pos('https://',lowercase(AUrl))=0) then
2599
     AUrl:='http://'+AUrl;
2600
     AUrl:='http://'+AUrl;
2600
 
2601
 
2601
  // Hinzugefügt
2602
  // Hinzugefügt
2602
  application.ProcessMessages;
2603
  if Assigned(Application) then Application.ProcessMessages;
2603
 
2604
 
2604
  hSession:=InternetOpen('InetURL:/1.0',
2605
  hSession:=InternetOpen('InetURL:/1.0',
2605
                         INTERNET_OPEN_TYPE_PRECONFIG,
2606
                         INTERNET_OPEN_TYPE_PRECONFIG,
2606
                         nil,
2607
                         nil,
2607
                         nil,
2608
                         nil,
2608
                         0);
2609
                         0);
2609
  if assigned(hsession) then
2610
  if assigned(hsession) then
2610
  begin
2611
  begin
2611
    // Hinzugefügt
2612
    // Hinzugefügt
2612
    application.ProcessMessages;
2613
    if Assigned(Application) then application.ProcessMessages;
2613
 
2614
 
2614
    hfile:=InternetOpenUrl(
2615
    hfile:=InternetOpenUrl(
2615
           hsession,
2616
           hsession,
2616
           pchar(AUrl),
2617
           pchar(AUrl),
2617
           nil,
2618
           nil,
Line 2620... Line 2621...
2620
           0);
2621
           0);
2621
    dwIndex  := 0;
2622
    dwIndex  := 0;
2622
    dwCodeLen := 10;
2623
    dwCodeLen := 10;
2623
 
2624
 
2624
    // Hinzugefügt
2625
    // Hinzugefügt
2625
    application.ProcessMessages;
2626
    if Assigned(Application) then application.ProcessMessages;
2626
 
2627
 
2627
    HttpQueryInfo(hfile,
2628
    HttpQueryInfo(hfile,
2628
                  HTTP_QUERY_STATUS_CODE,
2629
                  HTTP_QUERY_STATUS_CODE,
2629
                  @dwcode,
2630
                  @dwcode,
2630
                  dwcodeLen,
2631
                  dwcodeLen,
Line 2638... Line 2639...
2638
                              dwNumber,
2639
                              dwNumber,
2639
                              DwRead)) do
2640
                              DwRead)) do
2640
      begin
2641
      begin
2641
 
2642
 
2642
        // Hinzugefügt
2643
        // Hinzugefügt
2643
        application.ProcessMessages;
2644
        if Assigned(Application) then application.ProcessMessages;
2644
 
2645
 
2645
        if dwRead =0 then
2646
        if dwRead =0 then
2646
          break;
2647
          break;
2647
        databuffer[dwread]:=#0;
2648
        databuffer[dwread]:=#0;
2648
        Str := pchar(@databuffer);
2649
        Str := pansichar(@databuffer);
2649
        resStr := resStr + Str;
2650
        resStr := resStr + Str;
2650
      end;
2651
      end;
2651
    end
2652
    end
2652
    else
2653
    else
2653
      ResStr := 'Status:'+res;
2654
      ResStr := 'Status:'+AnsiString(res);
2654
    if assigned(hfile) then
2655
    if assigned(hfile) then
2655
      InternetCloseHandle(hfile);
2656
      InternetCloseHandle(hfile);
2656
  end;
2657
  end;
2657
 
2658
 
2658
  // Hinzugefügt
2659
  // Hinzugefügt
2659
  application.ProcessMessages;
2660
  if Assigned(Application) then application.ProcessMessages;
2660
 
2661
 
2661
  InternetCloseHandle(hsession);
2662
  InternetCloseHandle(hsession);
2662
  Result := resStr;
2663
  Result := resStr;
2663
end;
2664
end;
2664
 
2665