想获取PDA连接到台式电脑的连接状态,
找到一段C++的代码:RASCONN rsconn[10];
DWORD dwcb, dwConnections;
RASCONNSTATUS rasStatus; // Enumerate active connections
dwcb = sizeof(rsconn);
rsconn[0].dwSize = sizeof(RASCONN);
if(RasEnumConnections(rsconn, &dwcb, &dwConnections) == 0)
{
if(dwConnections == 0 || rsconn[0].hrasconn == NULL)
{
MessageBox(_T("No current connections"));
return;
}
// Get first RAS connection status
rasStatus.dwSize = sizeof(rasStatus);
if(RasGetConnectStatus(rsconn[0].hrasconn, &rasStatus) != 0)
{
MessageBox(_T("Could not get RAS connection status") );
return;
}
if(rasStatus.rasconnstate != RASCS_Connected)
{
MessageBox( _T("Not connected") );
return;
}
else
{
// I got it ... one RAS connection alive
}
}
else
MessageBox(_T("Could not enumerate RAS connections"));
想封装一下,用在C#里面调用,求助。
找到一段C++的代码:RASCONN rsconn[10];
DWORD dwcb, dwConnections;
RASCONNSTATUS rasStatus; // Enumerate active connections
dwcb = sizeof(rsconn);
rsconn[0].dwSize = sizeof(RASCONN);
if(RasEnumConnections(rsconn, &dwcb, &dwConnections) == 0)
{
if(dwConnections == 0 || rsconn[0].hrasconn == NULL)
{
MessageBox(_T("No current connections"));
return;
}
// Get first RAS connection status
rasStatus.dwSize = sizeof(rasStatus);
if(RasGetConnectStatus(rsconn[0].hrasconn, &rasStatus) != 0)
{
MessageBox(_T("Could not get RAS connection status") );
return;
}
if(rasStatus.rasconnstate != RASCS_Connected)
{
MessageBox( _T("Not connected") );
return;
}
else
{
// I got it ... one RAS connection alive
}
}
else
MessageBox(_T("Could not enumerate RAS connections"));
想封装一下,用在C#里面调用,求助。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货