Solved

Win32 APIs RasEnumConnections()

Posted on 1998-07-11
2
241 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
[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
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

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

623 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