IWMPNetwork::getProxyName 方法

[与此页面关联的功能(Windows 媒体播放器 SDK)是旧版功能。 它已被 MediaPlayer 取代。 MediaPlayer 已针对Windows 10和Windows 11进行了优化。 Microsoft 强烈建议新代码尽可能使用 MediaPlayer 而不是 Windows 媒体播放器 SDK。 如果可能,Microsoft 建议重写使用旧 API 的现有代码以使用新 API。]

getProxyName 方法返回正在使用的代理服务器的名称。

语法

public System.String getProxyName(
  System.String bstrProtocol
);

Public Function getProxyName( _
  ByVal bstrProtocol As System.String _
) As System.String
Implements IWMPNetwork.getProxyName

参数

bstrProtocol [in]

作为协议名称的 System.String 。 有关支持的协议的列表,请参阅 支持的协议和文件类型

返回值

一个 System.String ,它是正在使用的代理服务器的名称。 仅当 IWMPNetwork.getProxySettings 返回值 2 (使用手动设置) 时,该值才有意义。

备注

除非调用应用程序在本地计算机或 Intranet 上运行,否则此方法失败。

示例

下面的代码示例使用 getProxyName 显示 HTTP 和 MMS 协议Windows 媒体播放器代理服务器名称。 AxWMPLib.AxWindowsMediaPlayer 对象由名为 player 的变量表示。

// String values to hold the results of calls to getProxyExceptionList. 
string proxyNameHTTP = "";
string proxyNameMMS = "";

// Test whether the HTTP proxy settings are manual.
if (player.network.getProxySettings("HTTP") == 2)
{
    proxyNameHTTP = player.network.getProxyName("HTTP");
}

// Test whether the MMS proxy settings are manual.
if (player.network.getProxySettings("MMS") == 2)
{
    proxyNameMMS = player.network.getProxyName("MMS");
}

// Store the proxy server names in a string array and display them using a multi-line
// text box. Unavailable proxy server names will display as "undefined".
proxyNames[0] = ("The current HTTP proxy server name is: " + proxyNameHTTP);
proxyNames[1] = ("The current MMS proxy server name is: " + proxyNameMMS);
proxyNameText.Lines = proxyNames;

' String values to hold the results of calls to getProxyExceptionList. 
Dim proxyNameHTTP As String = ""
Dim proxyNameMMS As String = ""

' Test whether the HTTP proxy settings are manual.
If (player.network.getProxySettings("HTTP") = 2) Then

    proxyNameHTTP = player.network.getProxyName("HTTP")

End If

' Test whether the MMS proxy settings are manual.
If (player.network.getProxySettings("MMS") = 2) Then

    proxyNameMMS = player.network.getProxyName("MMS")

End If

' Store the proxy server names in a string array and display them using a multi-line
' text box. Unavailable proxy server names will display as "undefined".
proxyNames(0) = ("The current HTTP proxy server name is: " + proxyNameHTTP)
proxyNames(1) = ("The current MMS proxy server name is: " + proxyNameMMS)
proxyNameText.Lines = proxyNames

要求

要求
版本
Windows 媒体播放器 9 系列或更高版本
命名空间
WMPLib
程序集
Interop.WMPLib.dll (Interop.WMPLib.dll.dll)

另请参阅

IWMPNetwork 接口 (VB 和 C#)

IWMPNetwork.getProxySettings (VB 和 C#)

IWMPNetwork.setProxyName (VB 和 C#)