@@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Shadowsocks.Util.SystemProxy
|
||||
{
|
||||
public static class RAS
|
||||
internal static class RemoteAccessService
|
||||
{
|
||||
private enum RasFieldSizeConstants
|
||||
{
|
||||
@@ -69,22 +64,28 @@ namespace Shadowsocks.Util.SystemProxy
|
||||
#endregion
|
||||
|
||||
public int dwSize;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=(int)RasFieldSizeConstants.RAS_MaxEntryName + 1)]
|
||||
public string szEntryName;
|
||||
|
||||
public int dwFlags;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.RAS_MaxPath + 1)]
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=(int)RasFieldSizeConstants.RAS_MaxPath + 1)]
|
||||
public string szPhonebookPath;
|
||||
}
|
||||
|
||||
[DllImport("rasapi32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern uint RasEnumEntries(
|
||||
string reserved, // reserved, must be NULL
|
||||
string lpszPhonebook, // pointer to full path and file name of phone-book file
|
||||
[In, Out] RasEntryName[] lprasentryname, // buffer to receive phone-book entries
|
||||
ref int lpcb, // size in bytes of buffer
|
||||
out int lpcEntries // number of entries written to buffer
|
||||
// reserved, must be NULL
|
||||
string reserved,
|
||||
// pointer to full path and file name of phone-book file
|
||||
string lpszPhonebook,
|
||||
// buffer to receive phone-book entries
|
||||
[In, Out] RasEntryName[] lprasentryname,
|
||||
// size in bytes of buffer
|
||||
ref int lpcb,
|
||||
// number of entries written to buffer
|
||||
out int lpcEntries
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -136,15 +136,6 @@ namespace Shadowsocks.Util.SystemProxy
|
||||
|
||||
// Notify the system that the registry settings have been changed and cause
|
||||
// the proxy data to be reread from the registry for a handle.
|
||||
// bReturn = NativeMethods.InternetSetOption(
|
||||
// IntPtr.Zero,
|
||||
// INTERNET_OPTION.INTERNET_OPTION_SETTINGS_CHANGED,
|
||||
// IntPtr.Zero, 0);
|
||||
// if ( ! bReturn )
|
||||
// {
|
||||
// Logging.Error("InternetSetOption:INTERNET_OPTION_SETTINGS_CHANGED");
|
||||
// }
|
||||
|
||||
bReturn = NativeMethods.InternetSetOption(
|
||||
IntPtr.Zero,
|
||||
INTERNET_OPTION.INTERNET_OPTION_PROXY_SETTINGS_CHANGED,
|
||||
@@ -167,7 +158,7 @@ namespace Shadowsocks.Util.SystemProxy
|
||||
public static void SetIEProxy(bool enable, bool global, string proxyServer, string pacURL)
|
||||
{
|
||||
string[] allConnections = null;
|
||||
var ret = RAS.GetAllConns(ref allConnections);
|
||||
var ret = RemoteAccessService.GetAllConns(ref allConnections);
|
||||
|
||||
if (ret == 2)
|
||||
throw new Exception("Cannot get all connections");
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using Shadowsocks.Controller;
|
||||
@@ -224,21 +221,16 @@ namespace Shadowsocks.Util
|
||||
.OpenSubKey(name, writable);
|
||||
return userKey;
|
||||
}
|
||||
catch (UnauthorizedAccessException uae)
|
||||
{
|
||||
Logging.LogUsefulException(uae);
|
||||
return null;
|
||||
}
|
||||
catch (SecurityException se)
|
||||
{
|
||||
Logging.LogUsefulException(se);
|
||||
return null;
|
||||
}
|
||||
catch (ArgumentException ae)
|
||||
{
|
||||
MessageBox.Show("OpenRegKey: " + ae.ToString());
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging.LogUsefulException(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsWinVistaOrHigher() {
|
||||
|
||||
Reference in New Issue
Block a user