Solved

RAS function

Posted on 2000-05-07
8
240 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

776 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