IWMPNetwork::getProxyPort 方法
[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]
getProxyPort 方法返回正在使用的代理端口。
语法
public System.Int32 getProxyPort(
System.String bstrProtocol
);
Public Function getProxyPort( _
ByVal bstrProtocol As System.String _
) As System.Int32
Implements IWMPNetwork.getProxyPort
参数
-
bstrProtocol [in]
-
作为协议名称的 System.String 。 有关支持的协议的列表,请参阅 支持的协议和文件类型。
返回值
一个 System.Int32 ,它是正在使用的代理端口。 仅当 IWMPNetwork.getProxySettings 返回值 2 (使用手动设置) 时,该值才有意义。
备注
除非调用应用程序在本地计算机或 Intranet 上运行,否则此方法失败。
示例
下面的代码示例使用 getProxyPort 显示 MMS 和 HTTP 协议的当前Windows 媒体播放器代理端口号。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。
// Variables to hold the results of calls to getProxyPort.
int proxyPortHTTP = 0;
int proxyPortMMS = 0;
// Test whether the HTTP proxy settings are manual.
if (player.network.getProxySettings("HTTP") == 2)
{
proxyPortHTTP = player.network.getProxyPort("HTTP");
}
// Test whether the MMS proxy settings are manual.
if (player.network.getProxySettings("MMS") == 2)
{
proxyPortMMS = player.network.getProxyPort("MMS");
}
// Store the proxy port numbers in a string array and display them using a multi-line
// text box. Unavailable proxy port numbers will display as "undefined".
proxyPorts[0] = ("The current HTTP proxy port is: " + proxyPortHTTP.ToString());
proxyPorts[1] = ("The current MMS proxy port is: " + proxyPortMMS.ToString());
proxyPortText.Lines = proxyPorts;
' Variables to hold the results of calls to getProxyPort.
Dim proxyPortHTTP As Integer = 0
Dim proxyPortMMS As Integer = 0
' Test whether the HTTP proxy settings are manual.
If (player.network.getProxySettings("HTTP") = 2) Then
proxyPortHTTP = player.network.getProxyPort("HTTP")
End If
' Test whether the MMS proxy settings are manual.
If (player.network.getProxySettings("MMS") = 2) Then
proxyPortMMS = player.network.getProxyPort("MMS")
End If
' Store the proxy port numbers in a string array and display them using a multi-line
' text box. Unavailable proxy port numbers will display as "undefined".
proxyPorts(0) = ("The current HTTP proxy port is: " + proxyPortHTTP.ToString())
proxyPorts(1) = ("The current MMS proxy port is: " + proxyPortMMS.ToString())
proxyPortText.Lines = proxyPorts
要求
要求 | 值 |
---|---|
版本 |
Windows 媒体播放器 9 系列或更高版本 |
命名空间 |
WMPLib |
程序集 |
|
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈