本文整理汇总了C++中CNBUnitDevice::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CNBUnitDevice::GetName方法的具体用法?C++ CNBUnitDevice::GetName怎么用?C++ CNBUnitDevice::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNBUnitDevice
的用法示例。
在下文中一共展示了CNBUnitDevice::GetName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnGetDispInfo
LRESULT CNBBindListViewCtrl::OnGetDispInfo(LPNMHDR lParam)
{
NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(lParam);
CNBUnitDevice *obj;
obj = (CNBUnitDevice *)pDispInfo->item.lParam;
ATLASSERT( obj );
switch ( pDispInfo->item.iSubItem )
{
case 0: // Index
::_stprintf(
pDispInfo->item.pszText,
_T("%d"),
pDispInfo->item.iItem
);
break;
case 1: // Name
::_tcsncpy(
pDispInfo->item.pszText,
obj->GetName(),
pDispInfo->item.cchTextMax-1
);
break;
case 2: // ID
/*
::_tcsncpy(
pDispInfo->item.pszText,
phandler->GetStringID( obj ),
pDispInfo->item.cchTextMax-1
);
break;
case 3: // Size
*/
{
::_tcsncpy(
pDispInfo->item.pszText,
obj->GetCapacityString(),
pDispInfo->item.cchTextMax-1
);
}
default:
break;
}
pDispInfo->item.pszText[pDispInfo->item.cchTextMax-1] = '\0';
return 0;
}
示例2: OnSingle
void CMainFrame::OnSingle(UINT wNotifyCode, int wID, HWND hwndCtl)
{
CString strMsg;
CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();
if(!pDevice)
return;
if(!pDevice->GetCommandAbility(wID))
return;
CNBUnitDevice *pUnitDevice;
if(dynamic_cast<CNBLogicalDevice *>(pDevice))
{
CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
if(!pLogicalDevice || !pLogicalDevice->IsOperatableAll())
return;
pUnitDevice = (*pLogicalDevice)[0];
}
else
{
pUnitDevice = dynamic_cast<CNBUnitDevice *>(pDevice);
if(!pUnitDevice || !pUnitDevice->IsOperatable())
return;
}
if(!pUnitDevice)
return;
NBUnitDevicePtrList listUnitDevices;
listUnitDevices.push_back(pUnitDevice);
CNBSelectDeviceDlg dlgSelectDevice(
IDD_DEVICE_LIST,
IDS_SINGLE_DLG_CAPTION,
IDS_SINGLE_DLG_MESSAGE,
listUnitDevices,
0,
NULL,
NULL);
if(dlgSelectDevice.DoModal() != IDOK)
return;
NDASCOMM_CONNECTION_INFO ConnectionInfo;
if(!pUnitDevice->InitConnectionInfo(&ConnectionInfo, TRUE))
{
// "%1!s! does not have a write access privilege. You need to set write key to this NDAS device before this action."
strMsg.FormatMessage(IDS_ERROR_NOT_REGISTERD_WRITE_FMT,
pUnitDevice->GetName()
);
CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
MessageBox(
strMsg,
strTitle,
MB_OK|MB_ICONERROR
);
return;
}
AutoCursor l_auto_cursor(IDC_WAIT);
UINT32 BindResult = NdasOpBind(
1,
&ConnectionInfo,
NMT_SINGLE,
0);
l_auto_cursor.Release();
if(1 != BindResult)
{
DWORD dwLastError = ::GetLastError();
switch(dwLastError)
{
case NDASCOMM_ERROR_RW_USER_EXIST:
case NDASOP_ERROR_ALREADY_USED:
case NDASOP_ERROR_DEVICE_FAIL:
case NDASOP_ERROR_NOT_SINGLE_DISK:
case NDASOP_ERROR_DEVICE_UNSUPPORTED:
case NDASOP_ERROR_NOT_BOUND_DISK: // does not return this error
strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT, pUnitDevice->GetName());
break;
default:
strMsg.LoadString(IDS_BIND_FAIL);
break;
}
ShowErrorMessageBox(strMsg);
}
pUnitDevice->HixChangeNotify(pGetNdasHostGuid());
OnRefreshStatus(NULL, NULL, NULL);
}
示例3: RefreshStatus
BOOL CMainFrame::RefreshStatus()
{
AutoCursor l_auto_cursor(IDC_WAIT);
m_viewTreeList.GetTreeControl().DeleteAllItems();
ClearDevices();
// Initially, no commands are enabled
// UIEnableForDevice(pDevice, IDM_TOOL_BIND);
UIEnableForDevice(NULL, IDM_TOOL_UNBIND);
UIEnableForDevice(NULL, IDM_TOOL_ADDMIRROR);
UIEnableForDevice(NULL, IDM_TOOL_MIGRATE);
UIEnableForDevice(NULL, IDM_TOOL_REPLACE_DEVICE);
UIEnableForDevice(NULL, IDM_TOOL_REPLACE_UNIT_DEVICE);
UIEnableForDevice(NULL, IDM_TOOL_SINGLE);
UIEnableForDevice(NULL, IDM_TOOL_SPAREADD);
UIEnableForDevice(NULL, IDM_TOOL_SPAREREMOVE);
UpdateWindow();
// retrieve all the device & unit device information
if(!NdasEnumDevices( EnumDevicesCallBack, reinterpret_cast<LPVOID>(&m_listDevices)))
{
return FALSE;
}
m_wndRefreshProgress.ShowWindow(SW_SHOW);
m_wndRefreshProgress.SetRange32(0, m_listDevices.size());
m_wndRefreshProgress.SetStep(1);
m_wndRefreshProgress.SetPos(0);
// initialize all the unit devices
for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin();
itDevice != m_listDevices.end(); itDevice++)
{
if(!(*itDevice)->UnitDevicesInitialize())
{
// add single empty device
ATLTRACE(_T("Device not connected : %s\n"), (*itDevice)->GetName());
// m_wndRefreshProgress.ShowWindow(SW_HIDE);
// return FALSE;
}
m_wndRefreshProgress.StepIt();
}
// create logical devices
CNBUnitDevice *pUnitDevice;
CNBLogicalDevice *pLogicalDevice;
m_wndRefreshProgress.SetPos(0);
for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin();
itDevice != m_listDevices.end(); itDevice++)
{
for(UINT32 i = 0; i < (*itDevice)->UnitDevicesCount(); i++)
{
// find logical device which has this unit device as member
pLogicalDevice = NULL;
pUnitDevice = (*(*itDevice))[i];
ATLASSERT(pUnitDevice);
if(!pUnitDevice)
return FALSE;
for(NBLogicalDevicePtrList::iterator itLogicalDevice = m_listLogicalDevices.begin();
itLogicalDevice != m_listLogicalDevices.end(); itLogicalDevice++)
{
if((*itLogicalDevice)->IsMember(pUnitDevice))
{
// add to this logical device
pLogicalDevice = *itLogicalDevice;
ATLTRACE(_T("use CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName());
break;
}
}
if(NULL == pLogicalDevice)
{
// create new logical device
pLogicalDevice = new CNBLogicalDevice();
m_listLogicalDevices.push_back(pLogicalDevice);
ATLTRACE(_T("new CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName());
}
if(!pLogicalDevice->UnitDeviceAdd(pUnitDevice))
{
m_wndRefreshProgress.ShowWindow(SW_HIDE);
return FALSE;
}
}
m_wndRefreshProgress.StepIt();
}
m_viewTreeList.SetDevices(&m_listLogicalDevices);
m_wndRefreshProgress.ShowWindow(SW_HIDE);
return TRUE;
}
示例4: OnAddMirror
void CMainFrame::OnAddMirror(UINT wNotifyCode, int wID, HWND hwndCtl)
{
CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();
if(!pDevice)
return;
if(!pDevice->GetCommandAbility(wID))
return;
CNBLogicalDevice *pLogicalDevice = dynamic_cast<CNBLogicalDevice *>(pDevice);
if(!pLogicalDevice || pLogicalDevice->IsGroup())
return;
NBUnitDevicePtrList listUnitDevices = GetOperatableSingleDevices();
// remove self
listUnitDevices.remove((*pLogicalDevice)[0]);
CNBSelectDeviceDlg dlgSelectDevice(
IDD_DEVICE_LIST,
IDS_MIRROR_ADD_DLG_CAPTION,
IDS_MIRROR_ADD_DLG_MESSAGE,
listUnitDevices,
1,
CheckCapacityForMirror,
pLogicalDevice);
if(dlgSelectDevice.DoModal() != IDOK)
return;
CNBUnitDevice *pUnitDeviceAdd = dlgSelectDevice.GetSelectedDevice();
CNBUnitDevice *pUnitDevice = pUnitDevice = (*pLogicalDevice)[0];
// Bind & Synchronize
NDASCOMM_CONNECTION_INFO ConnectionInfo[2];
pUnitDevice->InitConnectionInfo(&ConnectionInfo[0], TRUE);
pUnitDeviceAdd->InitConnectionInfo(&ConnectionInfo[1], TRUE);
AutoCursor l_auto_cursor(IDC_WAIT);
UINT32 BindResult = NdasOpBind(
2,
ConnectionInfo,
NMT_SAFE_RAID1,
0);
l_auto_cursor.Release();
if(2 != BindResult)
{
CString strMsg;
DWORD dwLastError = ::GetLastError();
switch(dwLastError)
{
case NDASCOMM_ERROR_RW_USER_EXIST:
case NDASOP_ERROR_ALREADY_USED:
case NDASOP_ERROR_DEVICE_FAIL:
case NDASOP_ERROR_NOT_SINGLE_DISK:
case NDASOP_ERROR_DEVICE_UNSUPPORTED:
strMsg.FormatMessage(IDS_BIND_FAIL_AT_SINGLE_NDAS_FMT,
(BindResult == 0) ? pUnitDevice->GetName() : pUnitDeviceAdd->GetName());
break;
default:
strMsg.LoadString(IDS_BIND_FAIL);
break;
}
ShowErrorMessageBox(strMsg);
return;
}
pUnitDevice->HixChangeNotify(pGetNdasHostGuid());
pUnitDeviceAdd->HixChangeNotify(pGetNdasHostGuid());
/*
CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID1, IDS_RECOVERDLG_TASK_ADD_MIRROR);
ATLASSERT(FALSE);
// dlgRecover.SetMemberDevice(pUnitDeviceAdd);
dlgRecover.DoModal();
*/
OnRefreshStatus(NULL, NULL, NULL);
}
示例5: RefreshStatus
BOOL CMainFrame::RefreshStatus()
{
// lock
ActivateUI(FALSE);
m_viewTreeList.GetTreeControl().DeleteAllItems();
ClearDevices();
// retrieve all the device & unit device information
if(!NdasEnumDevices( EnumDevicesCallBack, reinterpret_cast<LPVOID>(&m_listDevices)))
return FALSE;
m_wndRefreshProgress.ShowWindow(SW_SHOW);
m_wndRefreshProgress.SetRange32(0, m_listDevices.size());
m_wndRefreshProgress.SetStep(1);
m_wndRefreshProgress.SetPos(0);
// initialize all the unit devices
for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin();
itDevice != m_listDevices.end(); itDevice++)
{
if(!(*itDevice)->UnitDevicesInitialize())
{
// add single empty device
ATLTRACE(_T("Device not connected : %s\n"), (*itDevice)->GetName());
// m_wndRefreshProgress.ShowWindow(SW_HIDE);
// return FALSE;
}
m_wndRefreshProgress.StepIt();
}
// create logical devices
CNBUnitDevice *pUnitDevice;
CNBLogicalDevice *pLogicalDevice;
m_wndRefreshProgress.SetPos(0);
for(NBNdasDevicePtrList::iterator itDevice = m_listDevices.begin();
itDevice != m_listDevices.end(); itDevice++)
{
/*
if(0 == (*itDevice)->UnitDevicesCount())
{
// suppose to be disconnected
pLogicalDevice = new CNBLogicalDevice();
pLogicalDevice->SetEmpty();
m_listLogicalDevices.push_back(pLogicalDevice);
ATLTRACE(_T("new CNBLogicalDevice(%p) : empty\n"), pLogicalDevice);
}
*/
for(UINT32 i = 0; i < (*itDevice)->UnitDevicesCount(); i++)
{
// find logical device which has this unit device as member
pLogicalDevice = NULL;
pUnitDevice = (*(*itDevice))[i];
ATLASSERT(pUnitDevice);
if(!pUnitDevice)
return FALSE;
for(NBLogicalDevicePtrList::iterator itLogicalDevice = m_listLogicalDevices.begin();
itLogicalDevice != m_listLogicalDevices.end(); itLogicalDevice++)
{
if((*itLogicalDevice)->IsMember(pUnitDevice))
{
// add to this logical device
pLogicalDevice = *itLogicalDevice;
ATLTRACE(_T("use CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName());
break;
}
}
if(NULL == pLogicalDevice)
{
// create new logical device
pLogicalDevice = new CNBLogicalDevice();
m_listLogicalDevices.push_back(pLogicalDevice);
ATLTRACE(_T("new CNBLogicalDevice(%p) : %s\n"), pLogicalDevice, pUnitDevice->GetName());
}
if(!pLogicalDevice->UnitDeviceAdd(pUnitDevice))
{
m_wndRefreshProgress.ShowWindow(SW_HIDE);
return FALSE;
}
}
m_wndRefreshProgress.StepIt();
}
m_viewTreeList.SetDevices(&m_listLogicalDevices);
m_wndRefreshProgress.ShowWindow(SW_HIDE);
ActivateUI(TRUE);
return TRUE;
}