This wininet sample demonstrates how to handle http authentication using InternetErrorDlg or custom UI.