检查拨号连接状态的代码

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, 00, PM_REMOVE))
        {
               TranslateMessage(
&msg);
               DispatchMessage(
&msg);
        }
        dwRet 
= RasGetConnectStatus(hRasConn, &rStatus);
    }
}
posted @ 2007-10-23 13:34  Rookie.Zhang  阅读(253)  评论(0)    收藏  举报