471,350 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Incorrect Structure Size of RasConnStatus

Hi everybody,
Unable to resolve the size of RasConnStatus which causing the
RasGetConnectStatus() of code # 632. Is there anyone who can tell me how to
get the correct size (structure) for the RasConstatus? Thanks in Advanced.

RasGetConnectStatus returning 632 error code.

Expand|Select|Wrap|Line Numbers
  1. [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto)]
  2. internal class RASCONNSTATUS
  3. {
  4. public int dwSize = 0;
  5. public RASCONNSTATE  rasconnstate;
  6. public int dwError = 0;
  7. [MarshalAs(UnmanagedType.ByValTStr,SizeConst=(int)RasFieldSizeConstants.
  8. RAS_MaxDeviceType+1)]
  9. public string szDeviceType = null;
  10. public string szDeviceName = null;
  11. }
  12.  
dennis

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200601/1
Jan 7 '06 #1
2 3484
Dennis Sia via DotNetMonster.com wrote:
Hi everybody,
Unable to resolve the size of RasConnStatus which causing the
RasGetConnectStatus() of code # 632. Is there anyone who can tell me how to
get the correct size (structure) for the RasConstatus? Thanks in Advanced. [StructLayout(LayoutKind.Sequential,CharSet=CharSet .Auto)]
internal class RASCONNSTATUS


Try
Marshal.SizeOf(typeof(RASCONNSTATUS))

Till
Jan 7 '06 #2
Thanks for replying, Till

Still causing a result of 632 even the connection is created.

Expand|Select|Wrap|Line Numbers
  1. private void btnRasConnect_Click(object sender, System.EventArgs e)
  2. {
  3. .. ..  ..
  4. if (this.CheckRasConnection(this.IDConnexionRAS) == false)
  5. this.OpeningConnection();
  6. ... ....
  7. }
  8.  
  9. private void OpeningConnection()
  10. {
  11. this.IDConnexionRAS = 0;
  12. string connectName = this.txtIpAddress.Text;
  13. string user = this.txtUsername.Text;
  14. string pass = this.txtPassword.Text;
  15.  
  16. this.OpenConnection(connectName,user,pass,"");
  17. }
  18.  
  19. public bool OpenConnection(string pNomConnection,string pUser,string
  20. pPassword,string pDomain)
  21. {
  22. int i;
  23. int j;
  24.  
  25. #region [ RASDIALPARAMS ]
  26. // The size of the table of bytes representing structure RASDIALPARAMS is of
  27. 1464 bytes
  28. TabParams = new byte[1464];
  29. BitConverter.GetBytes(1464).CopyTo(TabParams,0);
  30. i = 4;
  31. j = i;
  32. foreach (char Carac in pNomConnection)
  33. {
  34. BitConverter.GetBytes(Carac).CopyTo(TabParams, j);
  35. j += 2;
  36. }
  37. i += (42 + 258 + 98);
  38.  
  39. j = i;
  40. foreach (char Carac in pUser)
  41. {
  42. BitConverter.GetBytes(Carac).CopyTo(TabParams, j);
  43. j += 2;
  44. }
  45. i += 514;
  46. j = i;
  47. foreach (char Carac in pPassword)
  48. {
  49. BitConverter.GetBytes(Carac).CopyTo(TabParams, j);
  50. j += 2;
  51. }
  52. i += 514;
  53.  
  54. #endregion
  55.  
  56. uint res = RasDial(0,null,TabParams,0,0,ref IDConnexionRAS);
  57.  
  58. if (res == 0)
  59. {
  60. this.connectStatus = true;
  61. if (this.IDConnexionRAS > 0)
  62. this.IDDisconnectRAS = this.IDConnexionRAS;
  63.  
  64. status.rasconnstate = RASCONNSTATE.RASCS_Connected;
  65. RasAPI.RasConnectionNotification(IDConnexionRAS,this._DisconnEvent.
  66. Handle
  67. ,(int)RASNOTIFICATION.RASCN_Connection);
  68. Console.WriteLine ("RAS TRUE");
  69. this.lblConStat.Text = "Connected";
  70.  
  71. return true;
  72. }
  73. . .. .
  74. }
  75.  
  76. public bool GetRasConnectStatus(int idConn)
  77. {
  78. status = new RASCONNSTATUS();
  79. status.dwSize = Marshal.SizeOf(typeof(RASCONNSTATUS));
  80. //uint res = 1;
  81. res = RasAPI.RasGetConnectStatus(idConn, ref status);
  82.  
  83. if (res == 0 && status.rasconnstate == RASCONNSTATE.RASCS_Connected)
  84. {
  85. this.IsRasConnected = true;
  86. return true;
  87. }
  88. else
  89. {
  90. this.IsRasConnected = false;
  91. return false;
  92. }
  93. }
  94.  
  95.  
What is wrong? Something missing?

dennis

Till Meyer wrote:
Hi everybody,
Unable to resolve the size of RasConnStatus which causing the
RasGetConnectStatus() of code # 632. Is there anyone who can tell me how to
get the correct size (structure) for the RasConstatus? Thanks in Advanced.

[StructLayout(LayoutKind.Sequential,CharSet=CharSet .Auto)]
internal class RASCONNSTATUS


Try
Marshal.SizeOf(typeof(RASCONNSTATUS))

Till


--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...sharp/200601/1
Jan 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by ranjeet.gupta | last post: by
4 posts views Thread by marco_segurini | last post: by
6 posts views Thread by Laurent | last post: by
4 posts views Thread by junky_fellow | last post: by
15 posts views Thread by kris | last post: by
5 posts views Thread by =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post: by
6 posts views Thread by carles | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.