IWMPNetwork::setProxySettings 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 如果可能,Microsoft 强烈建议新代码使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
setProxySettings 方法指定协议的代理设置。
语法
public void setProxySettings(
System.String bstrProtocol,
System.Int32 lProxySetting
);
Public Sub setProxySettings( _
ByVal bstrProtocol As System.String, _
ByVal lProxySetting As System.Int32 _
)
Implements IWMPNetwork.setProxySettings
参数
-
bstrProtocol [in]
-
作为协议名称的 System.String 。 有关受支持协议的列表,请参阅 支持的协议和文件类型。
-
lProxySetting [in]
-
一个 System.Int32 ,它是下列值之一。
值 描述 0 “不使用代理服务器”。 1 使用当前浏览器的代理设置 (仅对 HTTP) 有效。 2 使用手动指定的代理设置。 3 自动检测代理设置。
返回值
此方法不返回值。
备注
除非调用应用程序在本地计算机或 Intranet 上运行,否则此方法将失败。
示例
下面的代码示例使用列表框允许用户为 HTTP 协议设置Windows 媒体播放器代理设置。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Load the list box with the proxy settings in order so that their index in the
// list box matches their value.
proxySettings.Items.Add("Do not use a proxy server. (Value = 0)");
proxySettings.Items.Add("Use the proxy settings of the current browser. Valid for HTTP only. (Value = 1)");
proxySettings.Items.Add("Use the manually specified proxy settings. (Value = 2)");
proxySettings.Items.Add("Auto-detect the proxy settings. (Value = 3)");
// Change the proxy setting for the HTTP protocol when the user makes a list box selection.
private void proxySettings_OnSelectedIndexChanged(object sender, System.EventArgs e)
{
// Store the index of the setting from the ListBox
int setting = ((System.Windows.Forms.ListBox)sender).SelectedIndex;
// Change the proxy setting.
player.network.setProxySettings("HTTP", setting);
}
' Load the list box with the proxy settings in order so that their index in the
' list box matches their value.
proxySettings.Items.Add("Do not use a proxy server. (Value = 0)")
proxySettings.Items.Add("Use the proxy settings of the current browser. Valid for HTTP only. (Value = 1)")
proxySettings.Items.Add("Use the manually specified proxy settings. (Value = 2)")
proxySettings.Items.Add("Auto-detect the proxy settings. (Value = 3)")
' Change the proxy setting for the HTTP protocol when the user makes a list box selection.
Public Sub proxySettings_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles proxySettings.SelectedIndexChanged
' Store the index of the setting from the ListBox
Dim lb As System.Windows.Forms.ListBox = sender
Dim setting As Integer = lb.SelectedIndex
' Change the proxy setting.
player.network.setProxySettings("HTTP", setting)
End Sub
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈