The Code Does Not Meaning Technique

what is technique?code is,the moderator of Bo Ke Yuan was thinked.
well, today only code can posted.
class CDialer 
{
public:
 
 CDialer(){
  m_hConnection = NULL;
  m_hParent = NULL;
  
 }
 
 ~CDialer(){ }
 
 void DestroyConnection(){
  if(NULL != m_hConnection){
   ConnMgrReleaseConnection(m_hConnection, FALSE);
   m_hConnection = NULL;
  } 
 } 
 
 BOOL EstablishConnection(int nItem){
  if(NULL == m_hParent )
   return FALSE;
  
  CONNMGR_DESTINATION_INFO stDestInfo;
  if(!get_Destination(nItem , stDestInfo))
   return FALSE;
  
  CONNMGR_CONNECTIONINFO stConnInfo;  
  ZeroMemory(&stConnInfo, sizeof(stConnInfo));
  stConnInfo.cbSize = sizeof(stConnInfo);
  stConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
  stConnInfo.dwPriority = CONNMGR_PRIORITY_USERBACKGROUND;
  stConnInfo.guidDestNet = stDestInfo.guid;
  stConnInfo.hWnd = m_hParent;
  stConnInfo.uMsg = WM_CMEVENT;
  
  HRESULT hResult = ConnMgrEstablishConnection(&stConnInfo, &m_hConnection);
  if(FAILED( hResult))
   return FALSE;
  
  return TRUE;
 } 
 
 void Create(HWND hParent){m_hParent = hParent;  }
 
 BOOL IsConnected(){
  if(NULL == m_hConnection)
   return FALSE;
  DWORD dwStatus;
  if(FAILED(ConnMgrConnectionStatus(m_hConnection, &dwStatus)))
   return FALSE;
  
  return dwStatus == CONNMGR_STATUS_CONNECTED;
 }
 
 //enum
 static size_t get_DestinationList(CDestinationVector& vecList) {
  CONNMGR_DESTINATION_INFO stDestInfo;
  for(int i = 0; SUCCEEDED(ConnMgrEnumDestinations(i, &stDestInfo)); i++){   
   vecList.push_back(stDestInfo);  
  }
  return vecList.size();
 }
 
 BOOL get_Destination(int nItem , CONNMGR_DESTINATION_INFO& stDestInfo){
  return SUCCEEDED(ConnMgrEnumDestinations(nItem, &stDestInfo)); 
 }
  
private:
 HANDLE m_hConnection;
 HWND   m_hParent; //mainframe
  
};

posted on 2004-07-13 15:17  LeighSword  阅读(308)  评论(1编辑  收藏  举报

导航