CString GetProxyServerFromRegistry() { CMyRegistry reg; char buf[MAX_PATH * 2] = ""; LPCSTR key = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; if (!reg.ChangeTo(HKEY_CURRENT_USER, key)) { Debug(__FUNCTION__ ": Could not change to %s\n", key); return buf; } DWORD dwEnabled; if (!reg.GetDword("ProxyEnable", &dwEnabled)) { Debug(__FUNCTION__ ": ProxyEnable key seems to be missing (this is normal)\n"); return buf; } if (!dwEnabled) { Debug(__FUNCTION__ ": Proxy is disabled (this is normal)\n"); return buf; } if (!reg.GetString("ProxyServer", buf, sizeof(buf))) { Debug(__FUNCTION__ ": ProxyServer key is not present (this is normal)\n"); return buf; } return buf; }
Programming Tips - Win32: get proxy server from registry
Date: 2021jul20
Platform: win32
Platform: MFC
Language: C/C++
Q. Win32: get proxy server from registry
A. Here is my code to get the control panel proxy server
It uses my registry class but its pretty clear how it works.
There is a way to exclude some hosts but that's non done here.