MSDN

Microsoft Docs

InternetSetStatusCallback function

Namespace: WinInet

Header: wininet.h

Library: Wininet.lib

Syntax

DWORD WINAPI InternetSetStatusCallback( HINTERNET hInternet, INTERNET_STATUS_CALLBACK lpfnInternetCallback );

Parameters

hInternetHandle to an Internet object. This can be a session, connection, request, or FTP file handle.
lpfnInternetCallbackPointer to the callback function that receives status notifications. Use NULL to remove the callback.

Return value

Returns the previous callback function pointer. If the function fails, the return value is NULL. Call GetLastError for extended error information.

Remarks

Requirements

Examples

The following example sets a status callback for an HTTP request and prints status messages to the console.

#include <windows.h> #include <wininet.h> #include <stdio.h> void CALLBACK StatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) { switch (dwInternetStatus) { case INTERNET_STATUS_RESOLVING_NAME: printf("Resolving host name...\n"); break; case INTERNET_STATUS_CONNECTING_TO_SERVER: printf("Connecting to server...\n"); break; case INTERNET_STATUS_SENDING_REQUEST: printf("Sending request...\n"); break; case INTERNET_STATUS_RECEIVING_RESPONSE: printf("Receiving response...\n"); break; default: break; } } int main(void) { HINTERNET hSession = InternetOpenA("MyAgent", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if (!hSession) return 1; InternetSetStatusCallback(hSession, StatusCallback); HINTERNET hConnect = InternetConnectA(hSession, "www.example.com", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); if (!hConnect) return 1; HINTERNET hRequest = HttpOpenRequestA(hConnect, "GET", "/", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0); if (!hRequest) return 1; HttpSendRequestA(hRequest, NULL, 0, NULL, 0); InternetCloseHandle(hRequest); InternetCloseHandle(hConnect); InternetCloseHandle(hSession); return 0; }

See Also