[ComImport]
[Guid("79EAC9D0-BAF9-11CE-8C82-00AA004BA90B")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IAuthenticate {
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void Authenticate(IntPtr phwnd,
[MarshalAs(UnmanagedType.LPWStr)] ref string pszUsername,
[MarshalAs(UnmanagedType.LPWStr)] ref string pszPassword);
}
<ComImport> _
<Guid("79EAC9D0-BAF9-11CE-8C82-00AA004BA90B")> _
<InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
Interface IAuthenticate
<MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)>
Sub Authenticate(IntPtr phwnd,
<MarshalAs(UnmanagedType.LPWStr)> ByRef string pszUsername,
<MarshalAs(UnmanagedType.LPWStr)> ByRef string pszPassword)
End Interface
None.
Example:
[ClassInterface(ClassInterfaceType.None)]
public class Downloader : IBindStatusCallback, IDisposable, IAuthenticate
{
public void Download()
{
URLDownloadToFile(IntPtr.Zero, SourcePath , LocalPath ,0,(IBindStatusCallback)this);
}
/// <summary>
/// Authenticates the specified user.
/// </summary>
/// <param name="phwnd">The HWND of the parent window for a default user interface.</param>
/// <param name="pszUsername">The username to use for authentication.
///Client should also set phwnd to zero.</param>
/// <param name="pszPassword">The password.</param>
public void Authenticate(IntPtr phwnd, ref string pszUsername, ref string pszPassword)
{
// Downloader.Authenticate implementation
phwnd = IntPtr.Zero;
pszUsername = "ProxyUserName";
pszPassword = "ProxyPassword";
}
}