Solved

Win32 APIs RasEnumConnections()

Posted on 1998-07-11
2
231 Views
Last Modified: 2010-04-01
I'm trying to use RasEnumConnections() and it is failing when I step over the line of code that calls this function.  Here is my code:

RASCONN RasConn;
DWORD* Buffer;
DWORD* NumberOfConnections;

RasConn.dwSize = sizeof(RASCONN);
RasConn.hrasconn = NULL;

RasEnumConnections(&RasConn,
               BufferSize,
               NumberOfConnections);

Do you know what I'm doing wrong.
0
Comment
Question by:ext3awf
2 Comments
 
LVL 8

Accepted Solution

by:
trestan earned 100 total points
ID: 1167582
You declare DWORD* Buffer; , But you use BufferSize, in your function call.

0
 
LVL 6

Expert Comment

by:alamo
ID: 1167583
There are other things wrong also.You declare Buffer and NumberOfConnections as pointers, because the function expects pointers. But your pointers are uninitialized - they don't point to anything.

You should declare Buffer and NumberOfConnections not as pointers but as the variables which RasEnumConnections need, and then pass their addresses to RasEnumConnections. Also, RasConn needs to be is an array of RASCONN  structures - there can be more than one connection, and the function will fail if you don't give it enough.

Try:
#define RasConn_Entries 10
RASCONN RasConn[RasConn_Entries];
DWORD BufferSize;
DWORD NumberOfConnections;

RasConn[0].dwSize = sizeof(RASCONN);
BufferSize = sizeof(RASCONN)*RasConn_Entries;

RasEnumConnections(&RasConn[0], &BufferSize, &NumberOfConnections);

That should work a lot better (though I haven't compiled or tested it). Hope this helps!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
C++ get user from AD  (VS6) 7 75
Why isn't object file created? 6 59
How to Correctly derive class from CWinThread in MFC 4 41
  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 …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 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