Solved

RAS function

Posted on 2000-05-07
8
252 Views
Last Modified: 2010-04-02
I need the sourcecode for a function which returns the number of RAS connections currently connected.

It needs to be simple (I'm not the best at Visual C). It would be really helpful if the full source of a console app could be posted.

I've looked at previous questions here, looked at RASBerry, and looked in news groups and have not yet found something simple enough for me to understand.

Thanks.
0
Comment
Question by:nedrub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 1

Expert Comment

by:yarond
ID: 2785770
You can use the RasEnumConnections functions with a big buffer, to get this back. for example:

RASCONN  rasConnData[200];
DWORD dwRetVal,dwConnSize,dwConnCount;
rasConnData[0].dwSize=sizeof(RASCONN);
dwConnSize=rasConnData[0].dwSize*200;
dwRetVal = RasEnumConnections( rasConnData, &dwConnSize, &dwConnCount);

In this case if the connections number is less than a 200, you'll get the number in dwConnCount.
You can do this more elegantly by passing 0 for dwConnSize, and then dynamically allocate the array of RASCONN structures... or just calculate the size with the returned dwConnSize/sizeof(RASCONN).

Not very elegant, but it should work.
0
 
LVL 3

Expert Comment

by:mitrakis
ID: 2785823
Oops...nedrub posted this Q twice.
I've already answered the other one...didn't see this Q before.

Regards
-Stavi-
0
 
LVL 1

Expert Comment

by:yarond
ID: 2785841
Didn't see the other one myself...
Anyway, yours came first.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:nedrub
ID: 2785897
Ooops indeed!!

I've just noticed the double-post. 6 minutes apart - must have pressed the browser's refresh button.

I'll blame the cat.

Sorry guys, no intention to muck you around.

Now, I know I'm going to seem really dumb here (it has been years since I've done anything with C and that was on unix - I haven't really got my head around VC++ yet), but I can get both lots of source to compile, but I get an error when it comes to linking ... source (using yarond's because I'm in this post) and output included below ...

What am I missing?

Thanks.

========================================

#include <windows.h>
#include "ras.h"

void main()
{
RASCONN  rasConnData[200];
DWORD dwRetVal,dwConnSize,dwConnCount;
rasConnData[0].dwSize=sizeof(RASCONN);
dwConnSize=rasConnData[0].dwSize*200;
dwRetVal = RasEnumConnections( rasConnData, &dwConnSize, &dwConnCount);
}

========================================

--------------------Configuration: test - Win32 Debug--------------------
Compiling...
RAS.cpp
Linking...
RAS.obj : error LNK2001: unresolved external symbol _RasEnumConnectionsA@12
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

test.exe - 2 error(s), 0 warning(s)

========================================

0
 
LVL 1

Accepted Solution

by:
yarond earned 200 total points
ID: 2785993
link rasapi32.lib
0
 
LVL 3

Expert Comment

by:mitrakis
ID: 2786489
yarond is right.
You have to add rasapi32.lib in your compiler/lib settings...forgot to mention this...uhhmm...I mean in the other post ;-)
0
 

Author Comment

by:nedrub
ID: 2786679
Adjusted points from 100 to 200
0
 

Author Comment

by:nedrub
ID: 2786680
Thanks guys, I've increased points due to the "double post issue" and the fact that I needed help with extra, basic issues.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question