dogankemal
New member
- Joined
- Dec 9, 2020
- Messages
- 1
- Programming Experience
- 3-5
I am using a proxy server on my C# app. If the app is running, the proxy server is active, if app is not running or crashed, I can disable proxy server but some users can shutdown computer without closing my app. When the computer is turned on, then proxy server is active, but my app is not running. After that they want to use internet but they have to "check your proxy server bla bla" until run my app or disabled from internet explorer.
By the way I wrote small, secondly .exe and it is running at system tray but some antiviruses and some times windows defender giving us "false positive". You can see how is changing regedit
I have two question;
By the way I wrote small, secondly .exe and it is running at system tray but some antiviruses and some times windows defender giving us "false positive". You can see how is changing regedit
C#:
public static class Proxy
{
[DllImport("wininet.dll")]
public static extern bool InternetSetOption
(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
public const int INTERNET_OPTION_SETTINGS_CHANGED = 39;
public const int INTERNET_OPTION_REFRESH = 37;
public static bool Kapat()
{
bool Sonuc = false;
try
{
bool settingsReturn, refreshReturn;
RegistryKey registry = Registry.CurrentUser.OpenSubKey
("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 0);
registry.SetValue("ProxyServer", 0);
if ((int)registry.GetValue("ProxyEnable", 1) == 1)
{
Sonuc = false;
}
else
{
Sonuc = true;
}
registry.Close();
settingsReturn = InternetSetOption
(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
refreshReturn = InternetSetOption
(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
}
catch (Exception)
{
Sonuc = false;
}
return Sonuc;
}
}
I have two question;
- How can I disable before when users shutdown computers without register?
- How can I change register keys in a safer way?