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.pocketpc.activesync    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:11 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);


}

}


}

}


Posted by Chris De Herrera on September 28, 2007, 3:52 pm
Please log in for more thread options
Hi,
I understand you want some assistance, however this is a developer question.

I suggest that you post developer questions in
microsoft.public.pocketpc.developer.


--
Chris De Herrera
http://www.pocketpcfaq.com
http://www.tabletpctalk.com
http://www.pocketpctalk.com
http://www.mobilitytalk.com

Windows Mobile Device Center FAQs -
http://www.pocketpcfaq.com/faqs/wmdc/index.htm
ActiveSync Troubleshooting Guide -
http://www.pocketpcfaq.com/faqs/t-shootactivesync.htm

> 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 it possible to make events show up on Pocket PC calendar? October 18, 2006, 3:20 pm
Steps to make activesync work with exchange server 2003 September 15, 2007, 1:46 pm
pocket pc and outlook pro 2003 May 26, 2007, 8:47 pm
WMDC and Pocket PC 2003 June 3, 2007, 5:14 pm
WMDC 6.1 and Pocket PC 2003 June 7, 2007, 2:11 am
Sync Exchange 2003 GAL with Pocket PC August 9, 2006, 10:15 am
Active Sync for Pocket PC 2003 August 19, 2007, 5:44 pm
bios Microsoft 2003 Pocket PC h3970 July 31, 2006, 10:56 am
ActievSync with Microsoft Device Emulator 4 Pocket PC WM 2003-SE November 18, 2005, 10:11 am
Vista, Pocket PC 2003 Pro, WMDC, Outlook 2007 June 4, 2007, 10:06 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap