VisualCpp.org Collection of Visual C++ Stuffs

9Apr/07Off

How can I check the internet connection Programmatically?

use InternetGetConnectedState API to reterive internet connection state

[ Code Snippet ]

DWORD dwRet = 0 ;

if(InternetGetConnectedState(&dwRet,0))
  AfxMessageBox("Computer is connected to Internet");
  else
  AfxMessageBox("Computer isnot connected to Internet\");

 For Further you can refer this  document for more information : http://www.pcausa.com/resources/InetActive.txt

Filed under: Networks Comments Off
4Mar/07Off

How to identify a user who is having specific kinds of privileges?

There are many ways to find Window User privilege but there is no specific function (like IsAdmin in Visual Basic). You can use NetUserGetInfo function to find out Window User Privilege


USER_INFO_1 usrInfo;
NetUserGetInfo(NULL,L"VcFaqs",1,(LPBYTE*)&usrInfo);

switch(usrInfo.usri1_priv)
{
 case USER_PRIV_GUEST:
          AfxMessageBox("Guest");
          break;
 case USER_PRIV_USER:
          AfxMessageBox("User");
          break;
 case USER_PRIV_ADMIN:
          AfxMessageBox("Administrator");
          break;
 default:
          MessageBox("Sorry :) wrong grp");
}