Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RAS function

Posted on 2000-05-07
8
Medium Priority
?
271 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 800 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

688 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