35. FAQ o Win API |
Q> How to break off connection?
A>
bool HangUp ()
{
RASCONN ras [20];
DWORD dSize, dNumber;
char szBuf [256];
ras [0].dwSize = sizeof (RASCONN);
dSize = sizeof (ras);//Get active RAS - Connection
DWORD dwRet = RasEnumConnections (ras, &dSize, &dNumber);
if (dwRet! = 0)
{
if (RasGetErrorString ((UINT) dwRet, (LPSTR) szBuf, 256)! = 0)
wsprintf ((LPSTR) szBuf, "Undefined RAS Enum Connections error (%ld).", dwRet
);
MessageBox ((LPSTR) szBuf, "RasHangUp", MB_OK | MB_ICONSTOP);
return false;
}
bool bOK = true;
for (DWORD dCount = 0; dCount <dNumber; dCount ++)
{//Hang up that connection
HRASCONN hRasConn = ras [dCount].hrasconn;
DWORD dwRet = RasHangUp (hRasConn);
if (dwRet! = 0)
{
char szBuf [256];
if (RasGetErrorString ((UINT) dwRet, (LPSTR) szBuf, 256)! = 0)
wsprintf ((LPSTR) szBuf, "Undefined RAS HangUp Error (%ld).", dwRet);
MessageBox ((LPSTR) szBuf, "RasHangUp", MB_OK | MB_ICONSTOP);
bOK = false;
}
}
return bOK;
}
|
2000 (c) DM