Click here to Skip to main content
15,894,646 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Code convertor tool in Vb .net Pin
Blumen8-May-07 2:14
Blumen8-May-07 2:14 
GeneralRe: Code convertor tool in Vb .net Pin
Dave Kreskowiak8-May-07 3:46
mveDave Kreskowiak8-May-07 3:46 
AnswerRe: Code convertor tool in Vb .net Pin
Paul Conrad4-May-07 14:00
professionalPaul Conrad4-May-07 14:00 
GeneralRe: Code convertor tool in Vb .net Pin
irrdev6-May-07 22:33
irrdev6-May-07 22:33 
QuestionRASEnumEntries for VB.NET Pin
hellotkb3-May-07 17:45
hellotkb3-May-07 17:45 
AnswerRe: RASEnumEntries for VB.NET Pin
Dave Kreskowiak4-May-07 6:26
mveDave Kreskowiak4-May-07 6:26 
GeneralRe: RASEnumEntries for VB.NET Pin
hellotkb4-May-07 20:12
hellotkb4-May-07 20:12 
GeneralRe: RASEnumEntries for VB.NET Pin
Claudio Nicora29-Nov-09 22:15
Claudio Nicora29-Nov-09 22:15 
@Dave: your code works perfectly, but on my side some cleanup was required.
So I decided to post a complete and clean version...
Private Const MAX_PATH As Integer = 260 + 1
Private Const MAX_RAS_ENTRY_NAMES As Integer = 256 + 1

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure RASENTRYNAME
	Public dwSize As Integer
	<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_RAS_ENTRY_NAMES)> _
	Public szEntryName As String
	Public dwFlags As Integer
	<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> _
	Public szPhonebook As String
End Structure

Private Declare Auto Function RasEnumEntries Lib "rasapi32.dll" ( _
	ByVal reserved As String, _
	ByVal phonebook As String, _
	<[In](), Out()> ByVal RasEntries() As RASENTRYNAME, _
	ByRef BufferSize As Integer, _
	ByRef EntryCount As Integer _
) As Integer

''' <summary>
''' Returns an array with available RAS connection names
''' </summary>
Public Shared Function GetConnectionsNames() As String()

	Dim res As New List(Of String)

	Try
		Dim bufferSize As Integer = Marshal.SizeOf(GetType(RASENTRYNAME))
		Dim entryCount As Integer = 1
		Dim entryNames(0) As RASENTRYNAME
		Dim rc As Integer

		entryNames(0).dwSize = Marshal.SizeOf(GetType(RASENTRYNAME))
		rc = RasEnumEntries(Nothing, Nothing, entryNames, bufferSize, entryCount)

		If rc = 0 Then
			' There was only one entry and it's been filled into the "dummy"
			' entry that we made before calling RasEnumEntries.
			res.Add(entryNames(0).szEntryName.Trim)

		ElseIf rc = 603 Then
			' 603 means that there are more entries than we have allocated space for.
			' So, expand the entryNames array and make sure we fill in the structure size
			' for every entry in the array!  This is important!!  Without it, you'll get 632 errors!
			ReDim entryNames(entryCount - 1)
			For i As Integer = 0 To entryCount - 1
				entryNames(i).dwSize = Marshal.SizeOf(GetType(RASENTRYNAME))
			Next
			rc = RasEnumEntries(Nothing, Nothing, entryNames, bufferSize, entryCount)
			For i As Integer = 0 To entryCount - 1
				res.Add(entryNames(i).szEntryName.Trim)
			Next

		Else
			' So if we get here, the call bombed. It would be a good idea to find out why here!
			MsgBox("Error reading RAS connections names, error code:" & rc.ToString(), MsgBoxStyle.SystemModal)

		End If

	Catch ex As Exception
		MsgBox("Error reading RAS connection names: " & ex.Message.ToString(), MsgBoxStyle.SystemModal)

	End Try

        Return res.ToArray

End Function

Thanks again.
Caudio


Visit my website for some interesting .NET free tools: http://coolsoft.altervista.org

AnswerRe: RASEnumEntries for VB.NET Pin
JfCode10-Jan-12 4:44
JfCode10-Jan-12 4:44 
Questionremoting problem Pin
neodeaths3-May-07 16:50
neodeaths3-May-07 16:50 
AnswerRe: remoting problem Pin
Paul Conrad14-Jul-07 6:50
professionalPaul Conrad14-Jul-07 6:50 
GeneralRe: remoting problem Pin
neodeaths15-Jul-07 16:46
neodeaths15-Jul-07 16:46 
GeneralRe: remoting problem Pin
Paul Conrad15-Jul-07 17:08
professionalPaul Conrad15-Jul-07 17:08 
Questionhow can i send infomation from 1 pc to another>? Pin
neodeaths3-May-07 16:12
neodeaths3-May-07 16:12 
AnswerRe: how can i send infomation from 1 pc to another>? Pin
Blumen3-May-07 23:07
Blumen3-May-07 23:07 
Question.NET Framework Content Training Pin
JatinerS3-May-07 13:43
JatinerS3-May-07 13:43 
QuestionProof of the .NET 3.0 Installation Pin
Brendan Vogt3-May-07 7:21
Brendan Vogt3-May-07 7:21 
AnswerRe: Proof of the .NET 3.0 Installation Pin
Dave Kreskowiak3-May-07 7:49
mveDave Kreskowiak3-May-07 7:49 
GeneralRe: Proof of the .NET 3.0 Installation Pin
Brendan Vogt3-May-07 19:54
Brendan Vogt3-May-07 19:54 
GeneralRe: Proof of the .NET 3.0 Installation Pin
Dave Kreskowiak4-May-07 2:28
mveDave Kreskowiak4-May-07 2:28 
QuestionRe: Proof of the .NET 3.0 Installation Pin
Brendan Vogt4-May-07 2:35
Brendan Vogt4-May-07 2:35 
AnswerRe: Proof of the .NET 3.0 Installation Pin
Scott Dorman4-May-07 4:08
professionalScott Dorman4-May-07 4:08 
AnswerRe: Proof of the .NET 3.0 Installation Pin
kubben3-May-07 14:04
kubben3-May-07 14:04 
GeneralRe: Proof of the .NET 3.0 Installation Pin
Brendan Vogt3-May-07 19:57
Brendan Vogt3-May-07 19:57 
GeneralRe: Proof of the .NET 3.0 Installation Pin
kubben4-May-07 1:53
kubben4-May-07 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.