Tech Off Thread

7 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Using RasGetEntryProperties in .NET CF

Back to Forum: Tech Off
  • User profile image
    NotSoTragic​Hero

     

    It seems that I can't get this right... I'm using the following signature:

     

    [DllImport("coredll.dll", CharSet = CharSet.Auto)]
        private extern static uint RasGetEntryProperties(string lpszPhoneBook, string szEntry, ref RASENTRY lpbEntry, ref int lpdwEntrySize, byte lpb, int lpdwSize);

     

    Calling it with the following parameters:

    RasGetEntryProperties(null, name, ref RasEntry, ref dwSize, 0, 128);

     

    However, whenever this is called, an error pops up on my device telling me there has been a native exception, without much detail.

    I've declared the RASENTRY struct as follows:

    private struct RASENTRY
        {
          public int dwSize;
          public int dwfOptions;
          public int dwCountryID;
          public int dwCountryCode;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxAreaCode + 1)]
          public string szAreaCode;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxPhoneNumber + 1)]
          public string szLocalPhoneNumber;
          public int dwAlternatesOffset;
          public RASIPADDR ipaddr;
          public RASIPADDR ipaddrDns;
          public RASIPADDR ipaddrDnsAlt;
          public RASIPADDR ipaddrWins;
          public RASIPADDR ipaddrWinsAlt;
          public int dwFrameSize;
          public int dwfNetProtocols;
          public int dwFramingProtocol;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH + 1)]
          public string szScript;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH + 1)]
          public string szAutoDialDll;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH + 1)]
          public string szAutoDialFunc;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxDeviceType + 1)]
          public string szDeviceType;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxDeviceName + 1)]
          public string szDeviceName;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxPadType + 1)]
          public string szX25PadType;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxX25Address + 1)]
          public string szX25Address;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxFacilities + 1)]
          public string szX25Facilities;
          [MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxUserData + 1)]
          public string szX25UserData;
          public int dwChannels;
          public int dwReserved1;
          public int dwReserved2;
          public int dwCustomAuthKey;
        }

     

    Any help would be appreciated, thanks!

     

    -Brandon

     

  • User profile image
    NotSoTragic​Hero

    *delete*

  • User profile image
    davewill

    DWORD RasGetEntryProperties(
      LPWSTR lpszPhoneBook,
      LPWSTR szEntry,
      LPRASENTRY lpbEntry,
      LPDWORD lpdwEntrySize,
      LPBYTE lpb,
      LPDWORD lpdwSize
    );

    "string lpb" might be the one that isn't right.  not sure though.

  • User profile image
    NotSoTragic​Hero

    davewill said:

    DWORD RasGetEntryProperties(
      LPWSTR lpszPhoneBook,
      LPWSTR szEntry,
      LPRASENTRY lpbEntry,
      LPDWORD lpdwEntrySize,
      LPBYTE lpb,
      LPDWORD lpdwSize
    );

    "string lpb" might be the one that isn't right.  not sure though.

    *delete*

  • User profile image
    NotSoTragic​Hero

    NotSoTragicHero said:
    davewill said:
    *snip*

    *delete*

    I've updated the first post to better reflect the current problem.  Thanks.

  • User profile image
    vletoux

    "int lpdwSize" should be "ref uint lpdwSize"


     

  • User profile image
    NotSoTragic​Hero

    vletoux said:

    "int lpdwSize" should be "ref uint lpdwSize"


     

    Thanks!  That at least stopped the native exception I was getting.

     

    However, the function now returns ERROR_NOINTERFACE.  Is the function definition still wrong?

    [DllImport("coredll.dll")]
            private extern static uint RasGetEntryProperties(string lpszPhoneBook, string szEntry, ref RASENTRY lpbEntry,
                ref uint lpdwEntrySize, byte lpb, ref uint lpdwSize);

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.