|
用c#写的在wm里拨号函数rasDial总是报错691,但是手动拨号可以
[复制链接]
大家好!
我用ras在phonebookEntry里面建立了一个entry要拨电信的#777,用户名ctnet@mycdma.cn,密码vnet.mobile,并把参数设置为了
rasEntry.dwCountryCode = 1;
rasEntry.dwfNetProtocols = 4;
rasEntry.dwfOptions = 4194824;
rasEntry.dwFramingProtocol = 1;
rasEntry.dwSize = 3472;
rasEntry.szDeviceName = "Cellular Line";
rasEntry.szDeviceType = "modem";
rasEntry.szLocalPhoneNumber = "#777";
lpb[0] = 180;
lpb[1] = 1;
lpb[4] = 180;
lpb[8] = 180;
lpb[9] = 1;
lpb[12] = 1;
lpb[16] = 15;
lpb[20] = 1;
lpb[24] = 2;
ret = RasSetEntryProperties(null, "ctnet", ref rasEntry, rasEntry.dwSize, lpb, lpbSize);
而且这个连接,我用多普达的机子t5399,windows mobile 6.5,测试后是可以手动连接上的。
后来我结合一些网站的代码,写了下面这个函数,每次测试时,都是报错,代码为691.网上的691错误解释是:因为用户名和/或密码在此域上无效,所以访问被拒绝。
我实在是搞不定了,请各位大侠求助!!!
public static void DialUp( )
{
IntPtr tmpRasSession = IntPtr.Zero;
//check the connection state first
if (IntPtr.Zero != m_pRasSession)
{
RASCONNSTATE resConnState = (RASCONNSTATE)GetStatus();
if (RASCONNSTATE.RASCS_Connected == resConnState ||
RASCONNSTATE.RASCS_PortOpened == resConnState ||
RASCONNSTATE.RASCS_DeviceConnected == resConnState ||
RASCONNSTATE.RASCS_AllDevicesConnected == resConnState ||
RASCONNSTATE.RASCS_Authenticate == resConnState ||
RASCONNSTATE.RASCS_AuthAck == resConnState ||
RASCONNSTATE.RASCS_Authenticated == resConnState)
{
return;
}
}
RASDIALPARAMS rasDialParams = new RASDIALPARAMS();
rasDialParams.size = Marshal.SizeOf(rasDialParams);
rasDialParams.entryName = "ctnet";
rasDialParams.userName = "ctnet@mycdma.cn";
rasDialParams.password = "vnet.mobile";
int lResult = RasDial(IntPtr.Zero, IntPtr.Zero, RASDIALPARAMS.ToBytes(rasDialParams), 0xFFFFFFFF, IntPtr.Zero, ref m_pRasSession);
//int t = RasDial(null, null, rasDialParams, 0xFFFFFFFF, null, ref m_pRasSession);
if (lResult != 0)
{
//throw new Exception(string.Format("RasDial failed: Error {0}", lResult));
int lStatus = RasHangUp(m_pRasSession);
//Marshal.FreeHGlobal(m_pRasSession);
MessageBox.Show(lResult.ToString(), "dial-up Error");
if (lStatus != 0)
MessageBox.Show(lStatus.ToString(), "hang-up Error");
}
}
|
|