Windows mobile 在Windows Mobile 6上隐藏GPRS连接失败通知不会';他似乎不在工作
我正在将Windows Mobile连接管理器支持添加到我的.NET Compact Framework 3.5应用程序中 我需要向用户隐藏连接错误,我已经阅读了MSDN文档并严格遵守了它(据我所知),但是如果GPRS无法连接,它们仍然会出现 这是我的C代码: 这是ConnMgrConnectionInfo结构的托管包装器:Windows mobile 在Windows Mobile 6上隐藏GPRS连接失败通知不会';他似乎不在工作,windows-mobile,compact-framework,Windows Mobile,Compact Framework,我正在将Windows Mobile连接管理器支持添加到我的.NET Compact Framework 3.5应用程序中 我需要向用户隐藏连接错误,我已经阅读了MSDN文档并严格遵守了它(据我所知),但是如果GPRS无法连接,它们仍然会出现 这是我的C代码: 这是ConnMgrConnectionInfo结构的托管包装器: [StructLayout(LayoutKind.Sequential)] public sealed class ConnMgrConnectionInfo {
[StructLayout(LayoutKind.Sequential)]
public sealed class ConnMgrConnectionInfo
{
Int32 cbSize; // DWORD
public ConnMgrParam dwParams = 0; // DWORD
public ConnMgrProxy dwFlags = 0; // DWORD
public ConnMgrPriority dwPriority = 0; // DWORD
public Int32 bExclusive = 0; // BOOL
public Int32 bDisabled = 0; // BOOL
public Guid guidDestNet = Guid.Empty; // GUID
public IntPtr hWnd = IntPtr.Zero; // HWND
public UInt32 uMsg = 0; // UINT
public Int32 lParam = 0; // LPARAM
public UInt32 ulMaxCost = 0; // ULONG
public UInt32 ulMinRcvBw = 0; // ULONG
public UInt32 ulMaxConnLatency = 0; // ULONG
// Constructors
public ConnMgrConnectionInfo()
{
cbSize = Marshal.SizeOf(typeof(ConnMgrConnectionInfo));
}
public ConnMgrConnectionInfo(Guid destination, ConnMgrPriority priority, ConnMgrProxy proxy)
: this()
{
guidDestNet = destination;
dwParams = ConnMgrParam.GuidDestNet;
dwPriority = priority;
dwFlags = proxy;
}
public ConnMgrConnectionInfo(Guid destination, ConnMgrPriority priority)
: this(destination, priority, ConnMgrProxy.NoProxy) { }
public ConnMgrConnectionInfo(Guid destination)
: this(destination, ConnMgrPriority.UserInteractive) { }
}
与此一起使用的是从connmgr.h定义C标志的枚举
[Flags]
public enum ConnMgrParam : int
{
GuidDestNet = 0x1,
MaxCost = 0x2,
MinRcvBw = 0x4,
MaxConnLatency = 0x8
}
[Flags]
public enum ConnMgrProxy : int
{
NoProxy = 0x0,
Http = 0x1,
Wap = 0x2,
Socks4 = 0x4,
Socks5 = 0x8,
SuspendAware = 0x10,
Registered_Home = 0x20,
No_Error_Msgs = 0x40,
WakeOnIncoming = 0x80,
}
public enum ConnMgrPriority
{
UserInteractive = 0x8000,
HighPriorityBackground = 0x0200,
LowPriorityBackground = 0x0008
}
以下是在连接管理器中“拨号”连接的相关PInvoke:
[DllImport("CellCore.dll", EntryPoint = "ConnMgrEstablishConnectionSync", SetLastError = true)]
public static extern int ConnMgrEstablishConnectionSync(ConnMgrConnectionInfo connectionInfo, ref IntPtr connectionHandle,
uint dwTimeout, ref ConnMgrStatus dwStatus);
const string scDefaultDestinationNetwork = "My ISP";
const uint dwTimeout = 60000;
ConnMgrStatus status = ConnMgrStatus.Unknown;
IntPtr pointerOut = IntPtr.Zero;
int retVal;
if (ConnectionEntry.DestinationNetwork == null)
{
ConnectionEntry.DestinationNetwork = scDefaultDestinationNetwork;
}
Guid destinationNetworkGuid = LookupGUIDforNetwork(ConnectionEntry.DestinationNetwork);
ConnMgrConnectionInfo info = new ConnMgrConnectionInfo(destinationNetworkGuid, ConnMgrPriority.HighPriorityBackground, ConnMgrProxy.No_Error_Msgs);
retVal = Win32PInvokes.ConnMgrEstablishConnectionSync(info, ref pointerOut, dwTimeout, ref status);
if (retVal == 0)
{
ConnectionEntry.Handle = pointerOut;
ConnectionFailures = 0;
}
else
{
ConnectionFailures++;
}
最后,以下代码使用正确的设置实例化ConnMgrConnectionInfo,然后从连接管理器请求连接:
[DllImport("CellCore.dll", EntryPoint = "ConnMgrEstablishConnectionSync", SetLastError = true)]
public static extern int ConnMgrEstablishConnectionSync(ConnMgrConnectionInfo connectionInfo, ref IntPtr connectionHandle,
uint dwTimeout, ref ConnMgrStatus dwStatus);
const string scDefaultDestinationNetwork = "My ISP";
const uint dwTimeout = 60000;
ConnMgrStatus status = ConnMgrStatus.Unknown;
IntPtr pointerOut = IntPtr.Zero;
int retVal;
if (ConnectionEntry.DestinationNetwork == null)
{
ConnectionEntry.DestinationNetwork = scDefaultDestinationNetwork;
}
Guid destinationNetworkGuid = LookupGUIDforNetwork(ConnectionEntry.DestinationNetwork);
ConnMgrConnectionInfo info = new ConnMgrConnectionInfo(destinationNetworkGuid, ConnMgrPriority.HighPriorityBackground, ConnMgrProxy.No_Error_Msgs);
retVal = Win32PInvokes.ConnMgrEstablishConnectionSync(info, ref pointerOut, dwTimeout, ref status);
if (retVal == 0)
{
ConnectionEntry.Handle = pointerOut;
ConnectionFailures = 0;
}
else
{
ConnectionFailures++;
}
此外,以下注册表设置设置为0以隐藏连接成功和断开连接消息:
HKEY_CURRENT_USER\ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}\Options (0)
HKEY_CURRENT_USER\ControlPanel\Notifications\{8ddf46e8-56ed-4750-9e58-afc6ce486d03}\Options (0)
现在,当代码触发时,连接错误仍然会在我们的kiosk风格的应用程序上弹出,允许用户点击设置并访问底层操作系统及其设置
有人能看出我做错了什么吗?以下是我的解决方案:
将以下注册表设置重新指向您自己的自定义exe:
HKEY\U LOCAL\U MACHINE\Software\Microsoft\Shell\Rai \:MSREMNET\1
它默认为\Windows中名为RemNet.exe的程序
如果传递了参数-RASERROR,则会弹出一个气球
我编写了自己的exe,有选择地忽略带有-RASERROR的调用,并将其余调用传递到原始RemNet:
#if DEBUG
string message = "OurRemNet called with:\r\n";
foreach (string arg in args)
{
message += arg + "\r\n";
}
MessageBox.Show(message);
string repeatparams = "";
foreach (string arg in args)
{
repeatparams += arg + " ";
}
Process.Start(@"\Windows\RemNet.exe", repeatparams);
#else
bool forwardToRemNet = true;
foreach(string arg in args)
{
if (arg == "-RASERROR")
{
forwardToRemNet = false;
}
}
if (forwardToRemNet)
{
string repeatparams = "";
foreach (string arg in args)
{
repeatparams += arg + " ";
}
Process.Start(@"\Windows\RemNet.exe", repeatparams);
}
#endif
我使用DEBUG开关生成一个EXE,告诉我发生了什么(调试),或者只是屏蔽ras错误(发布)以下是我的解决方案:
将以下注册表设置重新指向您自己的自定义exe:
HKEY\U LOCAL\U MACHINE\Software\Microsoft\Shell\Rai \:MSREMNET\1
它默认为\Windows中名为RemNet.exe的程序
如果传递了参数-RASERROR,则会弹出一个气球
我编写了自己的exe,有选择地忽略带有-RASERROR的调用,并将其余调用传递到原始RemNet:
#if DEBUG
string message = "OurRemNet called with:\r\n";
foreach (string arg in args)
{
message += arg + "\r\n";
}
MessageBox.Show(message);
string repeatparams = "";
foreach (string arg in args)
{
repeatparams += arg + " ";
}
Process.Start(@"\Windows\RemNet.exe", repeatparams);
#else
bool forwardToRemNet = true;
foreach(string arg in args)
{
if (arg == "-RASERROR")
{
forwardToRemNet = false;
}
}
if (forwardToRemNet)
{
string repeatparams = "";
foreach (string arg in args)
{
repeatparams += arg + " ";
}
Process.Start(@"\Windows\RemNet.exe", repeatparams);
}
#endif
我使用DEBUG开关构建一个EXE,告诉我发生了什么(DEBUG),或者只是屏蔽ras错误(RELEASE)作为旁白,我想出了一个解决方法。我只是延迟了检查连接是否正常的计时器,直到软件启动3分钟后才启动。不会隐藏任何其他故障,但会在引导后隐藏保证的故障。不,仍然会弹出间歇性错误消息。作为旁白,我想出了一个解决方法。我只是延迟了检查连接是否正常的计时器,直到软件启动3分钟后才启动。不会隐藏任何其他故障,但会在引导后隐藏保证的故障。不会,仍会弹出间歇性错误消息。