InternetWriteFile function (wininet.h)

Writes data to an open Internet file.


BOOL InternetWriteFile(
  [in]  HINTERNET hFile,
  [in]  LPCVOID   lpBuffer,
  [in]  DWORD     dwNumberOfBytesToWrite,
  [out] LPDWORD   lpdwNumberOfBytesWritten


[in] hFile

Handle returned from a previous call to FtpOpenFile or an HINTERNET handle sent by HttpSendRequestEx.

[in] lpBuffer

Pointer to a buffer that contains the data to be written to the file.

[in] dwNumberOfBytesToWrite

Number of bytes to be written to the file.

[out] lpdwNumberOfBytesWritten

Pointer to a variable that receives the number of bytes written to the file. InternetWriteFile sets this value to zero before doing any work or error checking.

Return value

Returns TRUE if the function succeeds, or FALSE otherwise. To get extended error information, call GetLastError. An application can also use InternetGetLastResponseInfo when necessary.


When the application is sending data, it must call InternetCloseHandle to end the data transfer.

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

Note  WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header wininet.h
Library Wininet.lib
DLL Wininet.dll

See also

Common Functions

WinINet Functions