Delphi Idhttp Component +idhttpserver component for file download service

Source: Internet
Author: User

http://blog.csdn.net/xxkku521/article/details/16864759Delphi idhttp Component +idhttpserver component for file download service2013-11-21 18:15 2624 People read comments (0) favorite reports Classification:DELPHI (Ten)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

[Delphi]View PlainCopy  
  1. Uses idhttp,idhttpserver;
  2. Idhttp Component Submission Download request
  3. Procedure Tvodservice.   Button3click (Sender:tobject);
  4. Var
  5. H:tidhttp;
  6. Mystream:tmemorystream;
  7. URL:string;
  8. Begin
  9. Mystream:=tmemorystream.   Create;
  10. H:=tidhttp.   Create (nil);
  11. url:=' http://192.168.0.254:9003/GetIni ';//Request Address
  12. Try
  13. H. Get (Url,mystream); Submit Request except
  14. Application.  Messagebox (' network error, please check network connection ',' Error box ', Mb_ok+mb_iconerror);
  15. MyStream.  Free;
  16. H. Free;
  17. Exit
  18. end;
  19. MyStream.   SaveToFile (Extractfilepath (Application. exename) +' system.ini ');
  20. MyStream.   Free;
  21. H. Free;
  22. End
  23. Idhttpsever Component Response Request
  24. Procedure Tvodservice. Datamodulecreate (Sender:tobject); //Initialize Idhttpserver components
  25. Var
  26. Hport:integer;
  27. Binding:tidsockethandle;
  28. Begin
  29. Try
  30. Vodhttpserver. Bindings.  Clear;
  31. Binding: = Vodhttpserver. Bindings.  ADD;
  32. Binding.  port:=9003;
  33. Binding.  ip:=' 192.168.0.254 ';
  34. Vodhttpserver.  Active:=true;
  35. except
  36. On e:exception do
  37. begin
  38. Frmmain_vodser. Write_logfile (' Load app settings error ' +e. Message);
  39. end;
  40. end;
  41. End
  42. Procedure Tvodservice.  Vodhttpservercommandget (Athread:tidpeerthread;
  43. Arequestinfo:tidhttprequestinfo; Aresponseinfo:tidhttpresponseinfo); //Response Request
  44. Var
  45. bytesent:cardinal;
  46. Localdoc:string;
  47. Tempstr,ips:string;
  48. Len,sport:integer;
  49. Begin
  50. Tempstr:=arequestinfo. Document; //Get request string
  51. Ips:=tidiohandlersocket (Athread. Connection. Iohandler). Binding. PeerIP; //Get request address
  52. Sport:=tidiohandlersocket (Athread. Connection. Iohandler). Binding. Peerport; //Get request Port
  53. if FileExists (Extractfilepath (Application. exename) +' system.ini ') Then
  54. begin
  55. Localdoc:=extractfilepath (Application. exename) +' system.ini ';
  56. Bytesent: =vodhttpserver.  Servefile (Athread, Aresponseinfo, Localdoc);
  57. End Else
  58. begin
  59. Application. Messagebox (' no file found system.ini!  ',' cue box ', mb_ok+mb_iconerror);
  60. end;
  61. End

Delphi Idhttp Component +idhttpserver component for file download service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.