title: How to send a HTTP POST Request in Delphi using WinInet api
body: <p>I am trying to make HTTP Requests from Delphi using the WinInet functions.</p>
  
  <p>So far I have:</p>
  
  <pre><code>function request:string;
  var
    hNet,hURL,hRequest: HINTERNET;
  begin
    hNet := InternetOpen(PChar('User Agent'),INTERNET_OPEN_TYPE_PRECONFIG or INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
    if Assigned(hNet) then 
    begin
    try
      hURL := InternetConnect(hNet,PChar('http://example.com'),INTERNET_DEFAULT_HTTP_PORT,nil,nil,INTERNET_SERVICE_HTTP,0,DWORD(0));
      if(hURL&lt;&gt;nil) then
        hRequest := HttpOpenRequest(hURL, 'POST', PChar('param=value'),'HTTP/1.0',PChar(''), nil, INTERNET_FLAG_RELOAD or INTERNET_FLAG_PRAGMA_NOCACHE,0);
      if(hRequest&lt;&gt;nil) then
        HttpSendRequest(hRequest, nil, 0, nil, 0);
      InternetCloseHandle(hNet);
    except
      on E : Exception do
        ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
    end;
    end
  end;
  </code></pre>
  
  <p>But this doesn't do anything (I am sniffing network http traffic to see if it works).
  I have successfully used InternetOpenURL but I also need to send POST request and that function doesn't do that.</p>
  
  <p>Could someone show me a simple example? The result I want is to get the http response page in a var as string.</p>