How can I retrieve a non-static proxy

  • Thread starter Thread starter Prehaut Anselme
  • Start date Start date
P

Prehaut Anselme

Hi,

I have found the script of the .pac where to obtain the specification to
obtain a proxy when we use IE

This adress is in the
HKCU\Softawre\Microsoft\Windows\CurrentVersion\Internet
Settings\AutoConfigURL

I have the adress of a script,

How can I obtain trough which proxy I need to pass ???

Thx

Anselme
 
Anselme,

You can get the proxy information by making a call to
WinGetHttpProxyForUrl. However, this shouldn't be needed, as the default
implementation of IWebProxy (returned through the static GetDefaultProxy on
the WebProxy class) should use the IE settings.

Hope this helps.
 
Thanx, I've found the "WinGetHttpProxyForUrl"

But how can I use it in my C# code ???

Thx for regards

Anselme


Nicholas Paldino said:
Anselme,

You can get the proxy information by making a call to
WinGetHttpProxyForUrl. However, this shouldn't be needed, as the default
implementation of IWebProxy (returned through the static GetDefaultProxy on
the WebProxy class) should use the IE settings.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Hi,

I have found the script of the .pac where to obtain the specification to
obtain a proxy when we use IE

This adress is in the
HKCU\Softawre\Microsoft\Windows\CurrentVersion\Internet
Settings\AutoConfigURL

I have the adress of a script,

How can I obtain trough which proxy I need to pass ???

Thx

Anselme
 
Prehaut,

You will have to make the following declarations:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_AUTOPROXY_OPTIONS
{
[MarshalAs(UnmanagedType.U4)]
public int dwFlags;
[MarshalAs(UnmanagedType.U4)]
public int dwAutoDetectFlags;
public stirng lpszAutoConfigUrl;
public IntPtr lpvReserved;
[MarshalAs(UnmanagedType.U4)]
public int dwReserved;
public bool fAutoLoginIfChallenged;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_PROXY_INFO
{

[MarshalAs(UnmanagedType.U4)]
public int dwAccessType;
public string lpszProxy;
public string lpszProxyBypass;
}

[DllImport("winhttp.dll", SetLastError=true, CharSet=CharSet.Unicode)]
public static extern bool WinHttpGetProxyForUrl(
IntPtr hSession,
string lpcwszUrl,
ref WINHTTP_AUTOPROXY_OPTIONS pAutoProxyOptions,
ref WINHTTP_PROXY_INFO pProxyInfo
);


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Thanx, I've found the "WinGetHttpProxyForUrl"

But how can I use it in my C# code ???

Thx for regards

Anselme


Nicholas Paldino said:
Anselme,

You can get the proxy information by making a call to
WinGetHttpProxyForUrl. However, this shouldn't be needed, as the default
implementation of IWebProxy (returned through the static GetDefaultProxy on
the WebProxy class) should use the IE settings.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Hi,

I have found the script of the .pac where to obtain the specification to
obtain a proxy when we use IE

This adress is in the
HKCU\Softawre\Microsoft\Windows\CurrentVersion\Internet
Settings\AutoConfigURL

I have the adress of a script,

How can I obtain trough which proxy I need to pass ???

Thx

Anselme
 
Thx a lot, it's exactly what I need, but, there's a little thing more.

How can I acces to the dwflags enumeration ?

I need to set dwflags to
WINHTTP_AUTOPROXY_CONFIG_URL
but how can I obtain this value ?

Thx a lot
Anselme

Nicholas Paldino said:
Prehaut,

You will have to make the following declarations:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_AUTOPROXY_OPTIONS
{
[MarshalAs(UnmanagedType.U4)]
public int dwFlags;
[MarshalAs(UnmanagedType.U4)]
public int dwAutoDetectFlags;
public stirng lpszAutoConfigUrl;
public IntPtr lpvReserved;
[MarshalAs(UnmanagedType.U4)]
public int dwReserved;
public bool fAutoLoginIfChallenged;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_PROXY_INFO
{

[MarshalAs(UnmanagedType.U4)]
public int dwAccessType;
public string lpszProxy;
public string lpszProxyBypass;
}

[DllImport("winhttp.dll", SetLastError=true, CharSet=CharSet.Unicode)]
public static extern bool WinHttpGetProxyForUrl(
IntPtr hSession,
string lpcwszUrl,
ref WINHTTP_AUTOPROXY_OPTIONS pAutoProxyOptions,
ref WINHTTP_PROXY_INFO pProxyInfo
);


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Thanx, I've found the "WinGetHttpProxyForUrl"

But how can I use it in my C# code ???

Thx for regards

Anselme


"Nicholas Paldino [.NET/C# MVP]" <[email protected]> a écrit
dans le message de news:[email protected]...
Anselme,

You can get the proxy information by making a call to
WinGetHttpProxyForUrl. However, this shouldn't be needed, as the default
implementation of IWebProxy (returned through the static
GetDefaultProxy
on
the WebProxy class) should use the IE settings.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I have found the script of the .pac where to obtain the
specification
 
Anselme,

It is probably declared in WinHttp.h, which would be included as part of
the platform SDK.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Thx a lot, it's exactly what I need, but, there's a little thing more.

How can I acces to the dwflags enumeration ?

I need to set dwflags to
WINHTTP_AUTOPROXY_CONFIG_URL
but how can I obtain this value ?

Thx a lot
Anselme

Nicholas Paldino said:
Prehaut,

You will have to make the following declarations:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_AUTOPROXY_OPTIONS
{
[MarshalAs(UnmanagedType.U4)]
public int dwFlags;
[MarshalAs(UnmanagedType.U4)]
public int dwAutoDetectFlags;
public stirng lpszAutoConfigUrl;
public IntPtr lpvReserved;
[MarshalAs(UnmanagedType.U4)]
public int dwReserved;
public bool fAutoLoginIfChallenged;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_PROXY_INFO
{

[MarshalAs(UnmanagedType.U4)]
public int dwAccessType;
public string lpszProxy;
public string lpszProxyBypass;
}

[DllImport("winhttp.dll", SetLastError=true, CharSet=CharSet.Unicode)]
public static extern bool WinHttpGetProxyForUrl(
IntPtr hSession,
string lpcwszUrl,
ref WINHTTP_AUTOPROXY_OPTIONS pAutoProxyOptions,
ref WINHTTP_PROXY_INFO pProxyInfo
);


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Thanx, I've found the "WinGetHttpProxyForUrl"

But how can I use it in my C# code ???

Thx for regards

Anselme


"Nicholas Paldino [.NET/C# MVP]" <[email protected]> a écrit
dans le message de Anselme,

You can get the proxy information by making a call to
WinGetHttpProxyForUrl. However, this shouldn't be needed, as the default
implementation of IWebProxy (returned through the static GetDefaultProxy
on
the WebProxy class) should use the IE settings.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I have found the script of the .pac where to obtain the
specification
to
obtain a proxy when we use IE

This adress is in the
HKCU\Softawre\Microsoft\Windows\CurrentVersion\Internet
Settings\AutoConfigURL

I have the adress of a script,

How can I obtain trough which proxy I need to pass ???

Thx

Anselme
 
Thanks for all

I'll try alone yet

Anselme

Nicholas Paldino said:
Anselme,

It is probably declared in WinHttp.h, which would be included as part of
the platform SDK.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Prehaut Anselme said:
Thx a lot, it's exactly what I need, but, there's a little thing more.

How can I acces to the dwflags enumeration ?

I need to set dwflags to
WINHTTP_AUTOPROXY_CONFIG_URL
but how can I obtain this value ?

Thx a lot
Anselme

"Nicholas Paldino [.NET/C# MVP]" <[email protected]> a écrit
dans le message de news:[email protected]...
Prehaut,

You will have to make the following declarations:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_AUTOPROXY_OPTIONS
{
[MarshalAs(UnmanagedType.U4)]
public int dwFlags;
[MarshalAs(UnmanagedType.U4)]
public int dwAutoDetectFlags;
public stirng lpszAutoConfigUrl;
public IntPtr lpvReserved;
[MarshalAs(UnmanagedType.U4)]
public int dwReserved;
public bool fAutoLoginIfChallenged;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct WINHTTP_PROXY_INFO
{

[MarshalAs(UnmanagedType.U4)]
public int dwAccessType;
public string lpszProxy;
public string lpszProxyBypass;
}

[DllImport("winhttp.dll", SetLastError=true, CharSet=CharSet.Unicode)]
public static extern bool WinHttpGetProxyForUrl(
IntPtr hSession,
string lpcwszUrl,
ref WINHTTP_AUTOPROXY_OPTIONS pAutoProxyOptions,
ref WINHTTP_PROXY_INFO pProxyInfo
);


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Thanx, I've found the "WinGetHttpProxyForUrl"

But how can I use it in my C# code ???

Thx for regards

Anselme


"Nicholas Paldino [.NET/C# MVP]" <[email protected]> a écrit
dans le message de Anselme,

You can get the proxy information by making a call to
WinGetHttpProxyForUrl. However, this shouldn't be needed, as the
default
implementation of IWebProxy (returned through the static GetDefaultProxy
on
the WebProxy class) should use the IE settings.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi,

I have found the script of the .pac where to obtain the specification
to
obtain a proxy when we use IE

This adress is in the
HKCU\Softawre\Microsoft\Windows\CurrentVersion\Internet
Settings\AutoConfigURL

I have the adress of a script,

How can I obtain trough which proxy I need to pass ???

Thx

Anselme
 
Back
Top