#include <stdio.h>
#include <windows.h>
#include <tchar.h>
#include <WinInet.h>
#pragma comment (lib,"Wininet.lib")
//为进程设置代理
bool SetConnectionProxy(const TCHAR *proxy_server)
{
TCHAR temp_string[256];
_tcscpy_s(temp_string, proxy_server);
HINTERNET hinternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
INTERNET_PER_CONN_OPTION options[2] = { 0 };
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
options[0].Value.dwValue = PROXY_TYPE_PROXY;
options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
options[1].Value.pszValue = temp_string;
INTERNET_PER_CONN_OPTION_LIST option_list = { sizeof(INTERNET_PER_CONN_OPTION_LIST) };
option_list.pOptions = options;
option_list.dwOptionCount = 2;
BOOL is_success = InternetSetOption(hinternet, INTERNET_OPTION_PER_CONNECTION_OPTION, &option_list, sizeof(option_list));
InternetCloseHandle(hinternet);
return is_success ? true : false;
}
int main(void)
{
SetConnectionProxy(_T("110.169.28.9:3128"));
getchar();
getchar();
return 0;
}
为进程设置代理
最新推荐文章于 2019-10-21 16:06:51 发布