Solved

RAS function

Posted on 2000-05-07
8
230 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now