http://blog.csdn.net/xxkku521/article/details/16864759

uses idhttp,IdHTTPServer;

//idhttp组件提交下载请求
procedure TVodService.Button3Click(Sender: TObject); 
var 
    h:TIdhttp; 
    MyStream:TMemoryStream; 
    url:string;
begin 
    MyStream:=TMemoryStream.Create; 
    h:=Tidhttp.Create(nil); 
    url:='http://192.168.0.254:9003/GetIni';//请求地址       
    try 
        h.get(url,MyStream);//提交请求     except   
        Application.Messagebox('网络出错,请检查网络连接','出错框',MB_OK+MB_ICONERROR) ;
        MyStream.Free;
        h.free; 
        exit; 
    end; 
    MyStream.SaveToFile(extractfilepath(application.exename)+'System.ini'); 
    MyStream.Free; 
    h.free;
end;

//IdHttpSever组件响应请求
procedure TVodService.DataModuleCreate(Sender: TObject);//初始化IdHttpServer组件
var
    hport:integer;
    Binding : TIdSocketHandle;
begin
    try
        VodHttpServer.Bindings.Clear;
        Binding := VodHttpServer.Bindings.Add;
        Binding.Port:=9003;
        binding.IP:='192.168.0.254';
        VodHttpServer.Active:=true;
    except
        on e:Exception do
            begin
                 FrmMain_VodSer.write_Logfile('加载APP设置error '+e.message);
            end;
    end;
end; 


procedure TVodService.VodHttpServerCommandGet(AThread: TIdPeerThread;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);//响应请求
var
    ByteSent: Cardinal;
    LocalDoc:string;
    tempstr,ips:string;
    len,sport:integer;
begin
    tempstr:=ARequestInfo.Document; //获取请求字符串
    ips:=TIdIOHandlerSocket(AThread.Connection.IOHandler).Binding.PeerIP;//获取请求地址
    sport:=TIdIOHandlerSocket(AThread.Connection.IOHandler).Binding.PeerPort;//获取请求端口
    if fileexists(extractfilepath(application.exename)+'System.ini') then
    begin
        LocalDoc:=extractfilepath(application.exename)+'System.ini';
        ByteSent :=VodHttpServer.ServeFile(AThread, AResponseInfo, LocalDoc);
    end else
    begin
        Application.Messagebox('没有找到文件System.ini!','提示框',MB_OK+MB_ICONERROR) ;
    end;
end;

 

dmdes.pas

unit dmdes; {*********************************************************} {* DELPHI、PHP、C#通用DES编码解码单元 *} {* 由TurboPower LockBox...

阅读全文

Delphi import unit per OpenSSL DLL RSA+MD5 signature

A nice contribute by Dim (Russia) Require libeay32.pas, v. >= 0.7 // Equivalent to: // openssl dgst -md5 -sign private.pem -hex -out ...

阅读全文

Hash a file with MD5

This tutorial continues from Encrypt a file. Setup Put another button on the main form and caption it "Hash". Add a THash compon...

阅读全文

Comments are closed, but trackbacks and pingbacks are open.