RAScreate and dial RAS connection on Win CE5.0


Hello Everyone,

I am trying to create and dial a RAS connection in Windows CE 5.0. I have a device running Win CE 5.0 and has GPRS modem on it. I want to "Make a connection" programatically and dial it.

I have followed all the instructions (i hope) given on the MSDN. However am not able to get through. I always get error "ERROR_INVALID_SIZE" (code 632) when I call RasGetEntryProperties().
I am now almost fed up. The size of RASENTRY i get is 3280


Following are the constants i Use (for Windows CE 5.0)
public const int RAS_MaxDeviceType = 16;
public const int RAS_MaxPhoneNumber = 128;
public const int RAS_MaxIpAddress = 15;
public const int RAS_MaxIpxAddress = 21;
public const int MAX_PATH = 260;//
public const int RAS_MaxEntryName = 20;
public const int RAS_MaxDeviceName = 32;
public const int RAS_MaxCallbackNumber = 48;


public const int RAS_MaxAreaCode = 10;
public const int RAS_MaxPadType = 32;
public const int RAS_MaxX25Address = 200;
public const int RAS_MaxFacilities = 200;
public const int RAS_MaxUserData = 200;
public const int RAS_MaxReplyMessage = 1024;
public const int RAS_MaxDnsSuffix = 256;
public const int UNLEN = 256;
public const int PWLEN = 256;
public const int DNLEN = 15;


Following is my RASENTRY structure

public struct RASENTRY
{
public uint dwSize;
public uint dwfOptions;
//
// Location/phone number.
//
public int dwCountryID;
public int dwCountryCode;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxAreaCode + 1)]
public string szAreaCode;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxPhoneNumber + 1)]
public string szLocalPhoneNumber;
public int dwAlternateOffset;
//
// PPP/Ip
//
public RASIPADDR ipaddr;
public RASIPADDR ipaddrDns;
public RASIPADDR ipaddrDnsAlt;
public RASIPADDR ipaddrWins;
public RASIPADDR ipaddrWinsAlt;
//
// Framing
//
public int dwFrameSize;
public int dwfNetProtocols;
public int dwFramingProtocol;
//
// Scripting
//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.MAX_PATH)]
public string szScript;
//
// AutoDial
//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.MAX_PATH)]
public string szAutodialDll;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.MAX_PATH)]
public string szAutodialFunc;
//
// Device
//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxDeviceType + 1)]
public string szDeviceType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxDeviceName + 1)]
public string szDeviceName;
//
// X.25
//
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxPadType + 1)]
public string szX25PadType;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxX25Address + 1)]
public string szX25Address;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxFacilities + 1)]
public string szX25Facilities;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxUserData + 1)]
public string szX25UserData;
public int dwChannels;
//
// Reserved
//
public int dwReserved1;
public int dwReserved2;

#if WINVERCE500

//
// EAP extension type to use
//
public int dwCustomAuthKey;

#endif

#if WINVER401

//
// Multilink and BAP
//
public int dwSubEntries;
public int dwDialMode;
public int dwDialExtraPercent;
public int dwDialExtraSampleSeconds;
public int dwHangUpExtraPercent;
public int dwHangUpExtraSampleSeconds;
//
// Idle time out
//
public int dwIdleDisconnectSeconds;

#endif

#if WINVER500

public EntryTypes dwType;
public EncryptionTypes dwEncryptionType;
public int dwCustomAuthKey;
public GUID guidId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
public string szCustomDialDll;
public int dwVpnStrategy;

#endif

#if WINVER501

public int dwfOptions2;
public int dwfOptions3;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxDnsSuffix + 1)]
public string szDnsSuffix;
public int dwTcpWindowSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RASConstants.MAX_PATH)]
public string szPrerequisitePbk;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)RASConstants.RAS_MaxEntryName + 1)]
public string szPrerequisiteEntry;
public int dwRedialCount;
public int dwRedialPause;

#endif

}


1. I have used # define WINVERCE500.
2. Is the RASENTRY structure size 3280 correct for Win CE 5.0

3. The function I call is dwGetEntry = RasGetEntryProperties(null, "gprs",ref RasEntry, ref dwSize, null, ref temp);
dwGetEntry is always 632 no matter what I do.

4. I have followed the correct RASENTRY structure as mentioned on MSDN. Plese point me where am I going wrong.

Please giude me in the right direction.

Thank you

cheers

Comments

  • Hi,

    Before call the function RasGetEntryProperties(), you must initialize the member dwSize of object RASENTRY with sizeof(RASENTRY).

    Good luck,
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion