Question

I'm trying to query the RasStatus of a connection. When I call the RasGetConnectStatus method, it returns 6. I've not found that particular return value in any of the documentation that I've read.

Here are some of the pages that I've looked at:

http://www.cs.scranton.edu/~beidler/Ada/win32/win32-raserror.html

http://msdn.microsoft.com/en-us/library/aa920162.aspx

http://msdn.microsoft.com/en-us/library/bb530704(v=vs.85).aspx

I'm using C# and .net 4.0

Edit: The code that actually calls follows:

uint result;
RASCONNSTATUS rasconnstatus; // http://pinvoke.net/default.aspx/Structures/RASCONNSTATUS.html
// _handle is previously set to the hwnd of the ras connection
result = RASAPI.RasGetConnectStatus(_handle, out rasconnstatus);

return rasconnstatus;

When this returns, result == 6 and rasconnstatus.rasconnstate == 0

What I need to find out is why result == 6.

Was it helpful?

Solution

The easiest way to look up Win32 error codes is by looking at the header files directly in the Windows SDK. Most of them are in the WinError.h file in the include folder wherever you installed the Windows SDK. For the RAS specific errors (the result would be between 600 and 900) those are in the RasError.h file.

In the case of your result being 6, it's indicating ERROR_INVALID_HANDLE; which in RAS that means it didn't like the connection handle you passed to the function. In your code sample, that would be _handle.

By the way, you may want to look at using the DotRas project on CodePlex, it's a .NET wrapper around the RAS API. The particular method you're interested in would be RasConnection.GetConnectionStatus, it returns the data from that structure.

foreach (RasConnection conn in RasConnection.GetActiveConnections())
{
    RasConnectionStatus status = conn.GetConnectionStatus();
    // Do something useful.
}

The WinError.h file is also available online here: http://msdn.microsoft.com/en-us/library/ms819772.aspx

Hope that helps!

OTHER TIPS

Here you should find your answer http://msdn.microsoft.com/en-us/library/aa920538.aspx this is the enum values of RASCONNSTATE returned by RasGetConnectStatus. The value 6 should equal to RASCS_AuthNotify and you will find this description:

An authentication event has occurred. If dwError is zero, this event will be immediately followed by one of the more specific authentication states following. If dwError is nonzero, authentication has failed, and the error value indicates why.

Maybe is related with some firewall rules that block the connection.

update the link is from windows mobile 6.5 documentation. for the windows one this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top