Using the Rasenumconnections function today, I found the example on MSDN to be wrong.
This is what the Rasenumconnections documentation on MSDN says:
Copy Code code as follows:
To determine the required buffer size, call Rasenumconnections with Lprasconn set to NULL. The variable pointed to by LPCB should is set to zero. The function would return the required buffer size into LPCB and an error code of Error_buffer_too_small.
The sample code provided on MSDN is also written like this:
Copy Code code as follows:
DWORD __cdecl wmain () {
DWORD DWCB = 0;
DWORD dwret = ERROR_SUCCESS;
DWORD dwconnections = 0;
Lprasconn lprasconn = NULL;
Dwret = Rasenumconnections (Lprasconn, &DWCB, &dwconnections);
if (Dwret = = Error_buffer_too_small) {
// ......
}
Unfortunately this example is wrong, at least on the XP SP3 is wrong, the Rasenumconnections function returns Error_invalid_size (632), not error_buffer_too_small. The solution is that the first parameter does not pass in null, but instead passes in a RASCONN structure with the correct set of dwsize, generally dwsize is set to sizeof (Rasconn), but if your program is to run on an earlier system, you need to hard The value of the code into the target system.