enable/disable ie proxy
enable ie proxy:
#include <stdio.h>
#include <conio.h>
#include <wininet.h>
int main(int argc, char **argv)
{
HKEY hKeyIn = HKEY_CURRENT_USER, hKeyOut;
if(RegOpenKeyEx(
hKeyIn,
"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
0,
KEY_CREATE_LINK | KEY_WRITE | KEY_READ | KEY_NOTIFY,
&hKeyOut) != ERROR_SUCCESS )
{
printf("RegOpenKeyEx Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings failed!\n");
getch();
return FALSE;
}
ULONG regsize = 0;
// LPBYTE pValue = new BYTE[regsize];
// memset(pValue, 0x01, regsize);
DWORD dwData=1;
if(RegSetValueEx(
hKeyOut,
"ProxyEnable",
0,
REG_DWORD,
(LPBYTE)&dwData,
sizeof(DWORD))!=ERROR_SUCCESS)
{
printf("RegSetValueEx ProxyEnable=1 failed!\n");
getch();
return FALSE;
}
RegCloseKey(hKeyOut);
//使设置生效
if(!InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0))
{
printf("InternetSetOption INTERNET_OPTION_SETTINGS_CHANGED failed!\n");
getch();
return FALSE;
}
if(!InternetSetOption(NULL, INTERNET_OPTION_REFRESH, NULL, 0))
{
printf("InternetSetOption INTERNET_OPTION_REFRESH failed!\n");
getch();
return FALSE;
}
return 0;
}
in mingw, link with lib wininet
to disable ie proxy, just change:
DWORD dwData=1;
to:
DWORD dwData=0;
补充:综合编程 , 其他综合 ,