在写ras拨号的时把256写错为20,这个糊涂问题居然花了我半天时间,
const int RAS_MaxEntryName = 256;
const int RAS_MaxPhoneNumber = 128;
const int RAS_MaxCallbackNumber = 128;
const int UNLEN = 256;
const int PWLEN = 256;
const int DNLEN = 15;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct RASDIALPARAMS
{
public int dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxEntryName + 1)]
public string szEntryName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxPhoneNumber + 1)]
public string szPhoneNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxCallbackNumber + 1)]
public string szCallbackNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = UNLEN + 1)]
public string szUserName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = PWLEN + 1)]
public string szPassword;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = DNLEN + 1)]
public string szDomain;
public int dwSubEntry;
public int dwCallbackId;
}
const int RAS_MaxPhoneNumber = 128;
const int RAS_MaxCallbackNumber = 128;
const int UNLEN = 256;
const int PWLEN = 256;
const int DNLEN = 15;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct RASDIALPARAMS
{
public int dwSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxEntryName + 1)]
public string szEntryName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxPhoneNumber + 1)]
public string szPhoneNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxCallbackNumber + 1)]
public string szCallbackNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = UNLEN + 1)]
public string szUserName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = PWLEN + 1)]
public string szPassword;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = DNLEN + 1)]
public string szDomain;
public int dwSubEntry;
public int dwCallbackId;
}