当前位置:编程学习 > 网站相关 >>

获取IE默认代理配置

BOOL GetWinetProxy(LPSTR lpszProxy, UINT nProxyLen)
{
unsigned long        nSize = 4096;
char                 szBuf[4096] = { 0 };
INTERNET_PROXY_INFO* pProxyInfo = (INTERNET_PROXY_INFO*)szBuf;
if(!InternetQueryOption(NULL, INTERNET_OPTION_PROXY, pProxyInfo, &nSize))
{
return FALSE;
}
if (pProxyInfo->dwAccessType == INTERNET_OPEN_TYPE_DIRECT)
{
return FALSE;

}

//这里是代理列表,以\0分隔,结束处两个\0\0,一般我们取第一条代理就够了

LPCSTR lpszProxyList = (LPCSTR)(pProxyInfo + 1);
int nLen = strlen(lpszProxyList);
if (lpszProxy)
{
nProxyLen = min(nLen, nProxyLen-1);
strncpy(lpszProxy, lpszProxyList, nProxyLen);
lpszProxy[nProxyLen] = 0;
}
return nLen;

 

/*INTERNET_PER_CONN_OPTION_LISTA    List;
INTERNET_PER_CONN_OPTIONA         Option[1];
unsigned long                    nSize = sizeof(INTERNET_PER_CONN_OPTION_LISTA);


Option[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
List.pszConnection = NULL;
List.dwOptionCount = 1;
List.dwOptionError = 0;
List.pOptions = Option;


if(!InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &List, &nSize))
{
return FALSE;
}
if(Option[0].Value.pszValue != NULL)
{
int nLen = strlen(Option[0].Value.pszValue);
if (lpszProxy)
{
nProxyLen = min(nLen, nProxyLen-1);
strncpy(lpszProxy, Option[0].Value.pszValue, nProxyLen);
lpszProxy[nProxyLen] = 0;
}
GlobalFree(Option[0].Value.pszValue);
return nLen;
}*/
return FALSE;
}

补充:综合编程 , 其他综合 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,