Solved

RAS function

Posted on 2000-05-07
8
264 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
Technology Partners: 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

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!

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 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…

626 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