CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
花落谁家,你作主! 盛大widget设计大赛英雄榜
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  C++ Builder >  基础类

怎么获得IE 代理服务器设置的用户名和密码?

楼主zxl777(龙啸九天)2004-09-03 22:20:14 在 C++ Builder / 基础类 提问

获取IE的代理服务器设置  
  [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet   Settings]  
  "ProxyEnable"=dword:00000001  
  "ProxyServer"="127.9.8.8:8080"  
   
  但用户名和密码怎么获得? 问题点数:0、回复次数:3Top

1 楼jiangsheng(蒋晟.Net[MVP])回复于 2004-09-04 07:11:54 得分 0

Under   Internet   Explorer   4.x   and   earlier,   the   InternetSetOption   and   InternetQueryOption   APIs   are   used   with   the   INTERNET_OPTION_PROXY   flag.   While   this   option   will   still   work   under   Internet   Explorer   5,   multiple   connection   options   have   been   introduced   in   the   new   version.   Given   this,   the   INTERNET_OPTION_PROXY   flag   will   return   only   the   "static"   proxy   server   setting.   The   static   option   is   the   proxy   server   information   stored   under   the   HKEY_CURRENT_USER   hive   much   the   same   way   it   was   under   Internet   Explorer   4.0  
   
  NOTE:   INTERNET_OPTION_PROXY   does   not   permanently   change   the   settings.   It   does   this   for   the   current   process   only   when   a   NULL   handle   is   used.   However,   it   can   also   change   the   settings   on   a   per   session   basis   if   a   valid   session   handle   is   sent   in   (session   handles   are   obtained   using   the   InternetOpen()   API).    
   
  If   under   Internet   Explorer   5,   you   specified   a   different   connection   option   (such   as   a   dial   up   connection)   as   the   default,   it   possible   that   the   proxy   information   you   obtain   using   the   INTERNET_OPTION_PROXY   flag   may   be   incorrect   for   the   current   Internet   Explorer   session.   For   this   reason,   under   Internet   Explorer   5,   it   is   recommended   that   the   INTERNET_OPTION_PER_CONNECTION_OPTION   be   used   instead.  
   
  NOTE:   INTERNET_OPTION_PER_CONNECTION_OPTION   causes   the   settings   to   be   changed   on   a   system-wide   basis   when   a   NULL   handle   is   used.   Or   to   set   the   settings   on   a   per   session   basis,   a   valid   session   handle   can   be   used.    
   
   
   
  MORE   INFORMATION  
  Under   Internet   Explorer   4.x,   a   typical   mechanism   to   query   the   proxy   information   would   look   something   like   this:  
   
   
   
  unsigned   long                 nSize   =   4096;  
  char                                   szBuf[4096]   =   {   0   };  
  INTERNET_PROXY_INFO*   pInfo   =   (INTERNET_PROXY_INFO*)szBuf;  
   
  if(!InternetQueryOption(NULL,   INTERNET_OPTION_PROXY,   pInfo,   &nSize))  
        printf("InternetQueryOption   failed!   (%d)\n",   GetLastError());    
  Under   Internet   Explorer   5,   the   recommended   way   is   to   use   code   similar   to   below:    
   
  INTERNET_PER_CONN_OPTION_LIST         List;  
  INTERNET_PER_CONN_OPTION                   Option[5];  
  unsigned   long                                         nSize   =   sizeof(INTERNET_PER_CONN_OPTION_LIST);  
   
  Option[0].dwOption   =   INTERNET_PER_CONN_AUTOCONFIG_URL;  
  Option[1].dwOption   =   INTERNET_PER_CONN_AUTODISCOVERY_FLAGS;  
  Option[2].dwOption   =   INTERNET_PER_CONN_FLAGS;  
  Option[3].dwOption   =   INTERNET_PER_CONN_PROXY_BYPASS;  
  Option[4].dwOption   =   INTERNET_PER_CONN_PROXY_SERVER;  
   
  List.dwSize   =   sizeof(INTERNET_PER_CONN_OPTION_LIST);  
  List.pszConnection   =   NULL;  
  List.dwOptionCount   =   5;  
  List.dwOptionError   =   0;  
  List.pOptions   =   Option;  
   
  if(!InternetQueryOption(NULL,   INTERNET_OPTION_PER_CONNECTION_OPTION,   &List,   &nSize))  
        printf("InternetQueryOption   failed!   (%d)\n",   GetLastError());  
        if(Option[0].Value.pszValue   !=   NULL)  
        printf("%s\n",   Option[0].Value.pszValue);  
   
  if((Option[2].Value.dwValue   &   PROXY_TYPE_AUTO_PROXY_URL)   ==   PROXY_TYPE_AUTO_PROXY_URL)  
      printf("PROXY_TYPE_AUTO_PROXY_URL\n");  
   
  if((Option[2].Value.dwValue   &   PROXY_TYPE_AUTO_DETECT)   ==   PROXY_TYPE_AUTO_DETECT)  
        printf("PROXY_TYPE_AUTO_DETECT\n");  
   
  INTERNET_VERSION_INFO             Version;  
  nSize   =   sizeof(INTERNET_VERSION_INFO);  
   
  InternetQueryOption(NULL,   INTERNET_OPTION_VERSION,   &Version,   &nSize);  
   
  if(Option[0].Value.pszValue   !=   NULL)  
        GlobalFree(Option[0].Value.pszValue);  
   
  if(Option[3].Value.pszValue   !=   NULL)  
        GlobalFree(Option[3].Value.pszValue);  
   
  if(Option[4].Value.pszValue   !=   NULL)  
        GlobalFree(Option[4].Value.pszValue);    
  The   code   above   specifies   the   connection   by   setting   the   pszConnection   string   in   the   INTERNET_PER_CONN_OPTION_LIST   structure.   By   setting   this   string   to   NULL,   the   configuration   information   will   be   retrieved   for   the   default   (or   LAN)   settings.  
   
  The   first   option   (Option[0]   INTERNET_PER_CONN_AUTOCONFIG_URL)   will   return   the   URL   specified   for   auto   configuration   of   the   proxy   server.   The   second   option   (Option[1]   INTERNET_PER_CONN_AUTODISCOVERY_FLAG)   will   detect   whether   the   auto   detect   option   is   enabled   or   not   for   the   connection   specified.   The   third   option   will   determine   what   combination   of   flags   have   been   set   for   this   particular   connection.   The   last   two   options   correspond   to   the   same   information   as   retrieved   whe   INTERNET_OPTION_PROXY   was   used   in   Internet   Explorer   4.x.  
   
  As   you   also   see,   the   options   that   can   potentially   return   string   values   are   freed   using   GlobalFree().   This   is   because   the   string   buffers   are   allocated   for   you   by   the   WININET   library,   and   it's   up   to   the   programmer   to   free   up   the   buffer   after   using   it.  
   
  To   obtain   information   for   a   different   connection,   simply   change   the   List.pszConnection   string   to   point   to   the   Dial-Up   setting   entry   you're   interested   it.  
   
  Similarly,   to   set   proxy   information,   you   would   use   the   same   technique   but   with   InternetSetOption()   instead,   for   example:  
   
   
  INTERNET_PER_CONN_OPTION_LIST         List;  
  INTERNET_PER_CONN_OPTION                   Option[1];  
  unsigned   long                                         nSize   =   sizeof(INTERNET_PER_CONN_OPTION_LIST);  
   
  Option[0].dwOption   =   INTERNET_PER_CONN_PROXY_SERVER;  
  Option[0].Value.pszValue   =   "http://myproxy:8080";  
   
  List.dwSize   =   sizeof(INTERNET_PER_CONN_OPTION_LIST);  
  List.pszConnection   =   NULL;  
  List.dwOptionCount   =   1;  
  List.dwOptionError   =   0;  
  List.pOptions   =   Option;  
   
  if(!InternetSetOption(NULL,   INTERNET_OPTION_PER_CONNECTION_OPTION,   &List,   nSize))  
        printf("InternetQueryOption   failed!   (%d)\n",   GetLastError());  
     
  Once   again,   the   above   sample   will   change   the   default   (or   LAN)   settings   (List.pszConnection   ==   NULL).   In   the   sample,   the   "static"   proxy   server   information   is   changed   to   "http://myproxy"   at   port   8080.   Similarly   you   can   also   change   the   auto   configuration   URL:  
   
   
   
  INTERNET_PER_CONN_OPTION_LIST         List;  
  INTERNET_PER_CONN_OPTION                   Option[2];  
  unsigned   long                                         nSize   =   sizeof(INTERNET_PER_CONN_OPTION_LIST);  
   
  Option[0].dwOption   =   INTERNET_PER_CONN_AUTOCONFIG_URL;  
  Option[0].Value.pszValue   =   "http://myserver/get_proxy_info.dll";  
  Option[1].dwOption   =   INTERNET_PER_CONN_FLAGS;  
  Option[1].Value.dwValue   =   PROXY_TYPE_AUTO_PROXY_URL;  
   
  List.dwSize   =   sizeof(INTERNET_PER_CONN_OPTION_LIST);  
  List.pszConnection   =   NULL;  
  List.dwOptionCount   =   2;  
  List.dwOptionError   =   0;  
  List.pOptions   =   Option;  
   
  if(!InternetSetOption(NULL,   INTERNET_OPTION_PER_CONNECTION_OPTION,   &List,   nSize))  
        printf("InternetQueryOption   failed!   (%d)\n",   GetLastError());  
     
  In   the   sample   above   (again   the   default   or   LAN   setting),   you   have   to   specify   the   auto   proxy   configuration   URL   and   set   the   option   flag   to   enable   the   auto   proxy   configurationTop

2 楼Leighf(好好生活,天天向上!)回复于 2005-06-23 10:07:46 得分 0

晕了Top

3 楼milkwayhong(自在)回复于 2005-06-23 10:28:29 得分 0

ft  
  @@Top

相关问题

  • 请教关于IE中代理服务器设置的编程问题!谢谢
  • 用vb编程!!如何更改IE的代理服务器设置!?
  • 代理服务器设置的问题
  • sygate代理服务器设置
  • 用c#如何编程实现获得本机的IE的◎代理服务器◎设置?
  • 如何使用VB修改IE中的代理服务器设置?(跪求详解~~)
  • 关于邮件发送时代理服务器设置问题?
  • 关于WinSock通讯的代理服务器设置问题
  • IE上网连接总是提示“正在检查代理服务器设置.....”的问题。解决后继续加分!
  • win98操作系统代理服务器设置问题(给100分)

关键词

  • internet
  • pszvalue
  • proxy
  • internetqueryoption
  • option
  • pszconnection
  • dwoption
  • nsize
  • conn
  • internetsetoption

得分解答快速导航

  • 帖主:zxl777

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo