检查拨号连接状态的代码
DWORD dwRet;
RASCONNSTATUS rStatus;
ZeroMemory(&rStatus, sizeof(RASCONNSTATUS));
rStatus.dwSize = sizeof(RASCONNSTATUS);
dwRet = RasGetConnectStatus(hRasConn, &rStatus);
if (dwRet != ERROR_INVALID_HANDLE)
{
RasHangUp(hRasConn); // hRasConn - valid handle to the RAS connection
MSG msg;
while (dwRet != ERROR_INVALID_HANDLE)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
dwRet = RasGetConnectStatus(hRasConn, &rStatus);
}
}
RASCONNSTATUS rStatus;
ZeroMemory(&rStatus, sizeof(RASCONNSTATUS));
rStatus.dwSize = sizeof(RASCONNSTATUS);
dwRet = RasGetConnectStatus(hRasConn, &rStatus);
if (dwRet != ERROR_INVALID_HANDLE)
{
RasHangUp(hRasConn); // hRasConn - valid handle to the RAS connection
MSG msg;
while (dwRet != ERROR_INVALID_HANDLE)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
dwRet = RasGetConnectStatus(hRasConn, &rStatus);
}
}