Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <wininet.h>
- #include <winhttp.h>
- #include <iostream>
- #pragma comment(lib, "Wininet.lib")
- #pragma comment(lib, "winhttp.lib")
- BOOL SetConnectionOptions()
- {
- INTERNET_PER_CONN_OPTION_LIST list;
- BOOL bReturn;
- DWORD dwBufSize = sizeof(list);
- // Fill the list structure.
- list.dwSize = sizeof(list);
- // NULL == LAN, otherwise connectoid name.
- list.pszConnection = NULL;
- // Set three options.
- list.dwOptionCount = 3;
- list.pOptions = new INTERNET_PER_CONN_OPTION[3];
- // Ensure that the memory was allocated.
- if (NULL == list.pOptions)
- {
- // Return FALSE if the memory wasn't allocated.
- return FALSE;
- }
- // Set flags.
- list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
- list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT |
- PROXY_TYPE_PROXY;
- // Set proxy name.
- list.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
- list.pOptions[1].Value.pszValue = (LPWSTR)TEXT("http=127.0.0.1:8888;https=127.0.0.1:8888");
- // Set proxy override.
- list.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
- list.pOptions[2].Value.pszValue = (LPWSTR)TEXT("local");
- // Set the options on the connection.
- bReturn = InternetSetOption(NULL,
- INTERNET_OPTION_PER_CONNECTION_OPTION, &list, dwBufSize);
- // Free the allocated memory.
- delete[] list.pOptions;
- return bReturn;
- }
- int main() {
- if (!SetConnectionOptions()) std::cout << "ERR: " << GetLastError();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement