0
votes

I want to change proxy settings from BHO before internet explorer navigate to a web address. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

I'm using RegOpenKeyEx , RegSetValueEx, RegCloseKey to change ProxyServer and ProxyEnable values in the BHO, BEFORENAVIGATE2 event. But when it open a registry with RegOpenKeyEx, the function return a value different than ERROR_SUCCESS. If I try to change registry with same code but from a simple program, not BHO, then this code will work, so it is not working in BHO.

RegOpenKeyEx return a LONG type value different than ERROR_SUCCESS which is equal to 5 , so it seems like it cannnot open registry. There is nothing to show, as my code is simple using those 3 functions to open registry and change values. If I do the same in a desktop program then it will successfuly open and change registry values. So I think it has some permissions issues with registry.

How to make it to work, or how to change proxy before internet explorer navugate to a web address, with or without registry ?

1
"Not working" supposedly has some error code. Also you might want to post some code around your RegXxx API use. - Roman R.
code is good, as I said this code is working in a normal program, but not work in bho dll, there is nothing to show, it just use 3 functions to work with registry as i said in my post and the return values of regOpenKeyEx is different than ERROR_SUCCESS - user971637
What are the ACTUAL return values? They are error codes that tell you what is actually wrong. - Remy Lebeau
@RemyLebeau RegOpenKeyEx return a LONG type value different than ERROR_SUCCESS which is equal to 5 - user971637
Error 5 is ERROR_ACCESS_DENIED. Not surprising, since a BHO runs in the IE process, and IE runs in a restricted (low integrity) process. - Remy Lebeau

1 Answers

0
votes

Internet Explorer uses the WinInet API for its connections, so you should be using the WinInet API to manipulate Internet Explorer's settings, specifically the InternetSetOption() function. Do not manipulate the Registry directly. Look at WinInet's INTERNET_OPTION_PROXY option, for instance.