首页
社区
课程
招聘
获取当前用户的IE代理信息
发表于: 2013-11-8 09:49 4327

获取当前用户的IE代理信息

2013-11-8 09:49
4327
函数功能:获取当前用户的IE代理信息

c++:

WINHTTP_CURRENT_USER_IE_PROXY_CONFIG proxyConfig;
WinHttpGetIEProxyConfigForCurrentUser(&proxyConfig);

返回值:

成功则返回true

我在xp sp3和2003,2000 sp4的服务中使用了这个函数,情况如下(包括匿名代理和无代理的情况)

无代理:

xp: OK

2003:OK

2000:服务崩溃

匿名代理:

xp: 函数返回值为 true,正确读取代理信息

2003:函数返回值为 false,正确读取代理信息

2000:服务崩溃

所以在xp sp3中使用还没有发现问题,但是在其他环境中,就比较复杂了。所以还是按照msdn上描述的,不要在服务中使用

WinHttpGetIEProxyConfigForCurrentUser,用别的方法取代。

#include "stdafx.h"

#include <Windows.h>
#include <Winhttp.h>

using namespace std;

void main()
{
        WINHTTP_CURRENT_USER_IE_PROXY_CONFIG MyProxyConfig;
        if(!WinHttpGetIEProxyConfigForCurrentUser(&MyProxyConfig))
        {
                //check the error
                DWORD Err = GetLastError();
                cout << "WinHttpGetIEProxyConfigForCurrentUser failed with the following error number: " << Err << endl;
                switch (Err)
                {
                        case ERROR_FILE_NOT_FOUND:
                                cout << "The error is ERROR_FILE_NOT_FOUND" << endl;
                                break;
                        case ERROR_WINHTTP_INTERNAL_ERROR:
                                cout << "ERROR_WINHTTP_INTERNAL_ERROR" << endl;
                                break;
                        case ERROR_NOT_ENOUGH_MEMORY:
                                cout << "ERROR_NOT_ENOUGH_MEMORY" << endl;
                                break;
                        default:
                                cout << "Look up error in header file." << endl;

                }//end switch
        }//end if
        else
        {
                //no error so check the proxy settings and free any strings
                cout << "Auto Detect is: " << MyProxyConfig.fAutoDetect << endl;
                if(NULL != MyProxyConfig.lpszAutoConfigUrl)
                {
                        wcout << "AutoConfigURL is: " << MyProxyConfig.lpszAutoConfigUrl << endl;
                        GlobalFree(MyProxyConfig.lpszAutoConfigUrl);
                }
                if(NULL != MyProxyConfig.lpszProxy)
                {
                        wcout << "AutoConfigURL is: " << MyProxyConfig.lpszProxy << endl;
                        GlobalFree(MyProxyConfig.lpszProxy);
                }
                if(NULL != MyProxyConfig.lpszProxyBypass)
                {
                        wcout << "AutoConfigURL is: " << MyProxyConfig.lpszProxyBypass << endl;
                        GlobalFree(MyProxyConfig.lpszProxyBypass);
                }

        }//end else
        cout << "finished!";
}//end main

[课程]Linux pwn 探索篇!

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 1140
活跃值: (3041)
能力值: ( LV12,RANK:385 )
在线值:
发帖
回帖
粉丝
2
http://support.microsoft.com/kb/873200/zh-cn
2013-11-8 10:42
0
游客
登录 | 注册 方可回帖
返回
//