Wrapping the RAS

Tags: .NET, C#, CodeSnippets

A couple of years ago I had a need to automate dialing a RAS connection and retrieving the IP address allocated by the server. I found myself writing a small, rather limited wrapper around the RAS P/Invoke calls. Far from complete, it only covered the functionality I needed for that project. But it was useful, and I kept it around.

Over the years I've had several people contact me to get a copy of that wrapper to save them time and effort, so to simplify matters, I'll simply attach my RasWrap project here and let google lead people to my blog, rather than to an ancient post on Channel9 where I last mentioned it.

The attachment contains two projects - the RasWrap project itself containing the P/Invoke signatures and wrapper classes to facilitate use, and a RasCaller project, a simple WinForm with example code on using the package.

Both are written for .NET 1.1, though they compiles and should work fine under 2.0.

The project includes a RasPhonebook class for iterating over a PBK file (RAS Phonebook), a RasEntry for retrieving information about an entry, and a RasConnection in order to dial or hang up against a RasEntry.

There is no support for writing new phonebook entries simply because I didn't need that functionality. If you have any problems, do let me know.

4 Comments

Comments have been disabled for this content.