如何在不使用Internet的情况下检索(获取)响应标头(Accept-Language)?

时间:2013-09-27 14:55:05

标签: c# vb.net vb6 http-headers httprequest

我希望得到用户Internet Explorer浏览器发送到网页(服务器)的“Accept-Language”标题。我想这样做而不连接到网页,但只是通过一些.dll COM调用或Windows API或其他一些方法,可以在不连接到互联网的情况下提供这些信息。我正在寻找跨越Window 2000 - Windows 8.1的最可靠的方法。

我愿意通过发出网络请求来获得这一点,但更愿意这样做,即:通过进行API调用或以真正的方式进行(无论是什么)。当我搜索互联网/谷歌时,人们只会显示涉及连接到某些服务器等的代码示例......而我找不到本地(非互联网)这样做的方法。

有人知道吗?我正在使用VB6(Visual Basic 6.0),但可以在VB.NET或C#中使用代码示例,因为它们很容易为我翻译。

1 个答案:

答案 0 :(得分:2)

接受语言存储在注册表中(Help: How to change the default language for Internet Explorer using C# code?):

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International
 REG_SZ: AcceptLanguage

 example en-gb,ar-eg;q=0.5

在vb.net中,它很简单(How to: Read a Value from a Registry Key in Visual Basic

Dim readValue = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International",
 "AcceptLanguage",Nothing)

在vb6中使用API​​是必要的,请参阅:Microsoft:How To Use the Registry API to Save and Retrieve Setting