Click here to get back home

i'm trying to make a list of RAS connections on a pocket pc 2003 d

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
i'm trying to make a list of RAS connections on a pocket pc 2003 d indika 09-28-2007
Get Chitika Premium
Posted by indika on September 28, 2007, 12:05 am
Please log in for more thread options
i'm trying to make a list of RAS connections on a pocket pc 2003 device . and
hear is my code. but it displaied only one connection on the combo box. it
should be 11 connections. can any one check this one and explain to me whats
wrong with this.



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;





using System.Runtime.InteropServices;

namespace Rastest

{


public partial class Form2 : Form

{


const int MAX_PATH = 260;

const int RAS_MaxEntryName = 20;

const int RAS_MaxDeviceType = 16;

const int RAS_MaxPhoneNumber = 128;

const int RAS_MaxDeviceName = 128;



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

struct RASCONN

{

public int dwSize;

public IntPtr hrasconn;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxEntryName + 1)]

public string szEntryName;

}

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

struct RASCONNSTATUS

{

public int dwSize;

public int rasconnstate;

public int dwError;

[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_MaxPhoneNumber + 1)]

public string szPhoneNumber;

}


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

struct RASENTRYNAME

{

public int dwSize;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = RAS_MaxEntryName + 1)]

public string szEntryName;

public int dwFlags;

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH + 1)]

public string szPhonebook;

}

[DllImport("coredll.dll", SetLastError = true)]//, CharSet = CharSet.Auto)]

static extern uint RasEnumEntries(IntPtr reserved, IntPtr lpszPhonebook,
[In, Out] RASENTRYNAME[] lprasentryname, ref int lpcb, ref int lpcEntries);

[DllImport("coredll.dll", SetLastError = true, CharSet = CharSet.Auto)]

static extern int RasEnumConnections([In, Out] RASCONN[] lprasconn,ref int
lpcb,ref int lpcConnections);

[DllImport("coredll.dll", SetLastError = true, CharSet = CharSet.Auto)]

static extern int RasGetConnectStatus(IntPtr hrasconn,ref RASCONNSTATUS
lprasconnstatus);




/// <summary>

/// </summary>


public Form2()

{

InitializeComponent();


int cb = Marshal.SizeOf(typeof(RASENTRYNAME)), entries = 0;

RASENTRYNAME[] entryNames = new RASENTRYNAME[1];

entryNames[0].dwSize = Marshal.SizeOf(typeof(RASENTRYNAME));

//Get entry number

uint nRet = RasEnumEntries(IntPtr.Zero, IntPtr.Zero, entryNames, ref cb, ref
entries);

if (entries == 0) return;

string[] _EntryNames = new string[entries];

entryNames = new RASENTRYNAME[entries];



nRet = RasEnumEntries(IntPtr.Zero, IntPtr.Zero, entryNames, ref cb, ref
entries);




this.connname(entries);




}

public void Form2_Load(object sender, EventArgs e)

{


}

public void connname(int entries)

{

int dwNumRasConnections = 0;

RASCONN[] lpRasConnArray = new RASCONN[entries];

lpRasConnArray.Initialize();

lpRasConnArray[0].dwSize = Marshal.SizeOf(typeof(RASCONN));

int dwRasConnArraySize = lpRasConnArray[0].dwSize * lpRasConnArray.Length;

//dwNumRasConnections = 0;

int nnRet = RasEnumConnections(lpRasConnArray, ref dwRasConnArraySize, ref
dwNumRasConnections);

// to the size of the structure to identify the version of the structure
being passed

lpRasConnArray[0].dwSize = Marshal.SizeOf(typeof(RASCONN));

//enumerate all active RAS connections

nnRet = RasEnumConnections(lpRasConnArray, ref dwRasConnArraySize, ref
dwNumRasConnections);

//return lpRasConnArray[dwNumRasConnections].szEntryName;

for (int i = 0; i < entries; i++)

{


this.comboBox1.Items.Add(lpRasConnArray.szEntryName);


}

}


}

}




Similar ThreadsPosted
Is there any procedure to make a MTC call on pocket pc phone emula April 3, 2007, 1:06 am
VS.NET 2003 Can't Make CABs June 24, 2005, 2:48 pm
list of smartphone 2003 devices October 6, 2005, 3:16 am
EVC 4 ,Smartphone 2003 ,GUI , List/Tree View Control June 23, 2005, 6:55 am
New Mail Transport for pocket pc 2003 February 17, 2006, 10:50 am
Pocket PC 2003 Wait Cursor July 26, 2006, 4:54 am
porting Pocket PC 2003 app to Windows Mobile 5.0 Smartphone May 15, 2006, 11:26 am
How to dinamically hang up GPRS connection (Pocket PC 2003 Device) March 18, 2008, 8:28 pm
Bluetooth max connections to a service. May 21, 2007, 6:04 am
How to turn on both GPRS and Wi-Fi connections at the same time?? March 21, 2006, 9:17 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap