本文整理汇总了C++中CDiskObjectPtr::CanAccessExclusive方法的典型用法代码示例。如果您正苦于以下问题:C++ CDiskObjectPtr::CanAccessExclusive方法的具体用法?C++ CDiskObjectPtr::CanAccessExclusive怎么用?C++ CDiskObjectPtr::CanAccessExclusive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDiskObjectPtr
的用法示例。
在下文中一共展示了CDiskObjectPtr::CanAccessExclusive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMigrate
BOOL CMirDiskUIHandler::OnMigrate(CDiskObjectPtr obj ) const
{
CMirDiskObjectPtr mirDisk =
boost::dynamic_pointer_cast<CMirDiskObject>(obj);
if(NMT_MIRROR != mirDisk->GetNDASMediaType())
return FALSE;
UINT32 BindResult;
CDiskObjectPtr disk = obj;
NDASCOMM_CONNECTION_INFO pConnectionInfo[NUMBER_MIGRATE_DISK];
UINT32 i;
WTL::CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
// Find aggregation root
if (NUMBER_MIGRATE_DISK != disk->GetDiskCount())
{
WTL::CString strMsg;
strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_DISK_NOT_EXIST );
MessageBox(
::GetFocus(),
strMsg,
strTitle,
MB_OK | MB_ICONWARNING
);
return FALSE;
}
WTL::CString strConfirmMsg;
strConfirmMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_CONFIRM );
if ( IDYES != MessageBox(
::GetFocus(),
strConfirmMsg,
strTitle,
MB_YESNO | MB_ICONWARNING
)
)
{
return FALSE;
}
if ( !disk->CanAccessExclusive() )
{
WTL::CString strMsg;
strMsg.LoadString( IDS_FAIL_TO_ACCESS_EXCLUSIVELY );
MessageBox(
::GetFocus(),
strMsg,
strTitle,
MB_OK | MB_ICONWARNING
);
return FALSE;
}
CDiskObjectCompositePtr pDiskObjectComposite =
boost::dynamic_pointer_cast<CDiskObjectComposite>(disk);
CDiskObjectComposite::const_iterator itr;
for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
{
CUnitDiskObjectPtr unitDisk =
boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
ZeroMemory(&pConnectionInfo[i], sizeof(NDASCOMM_CONNECTION_INFO));
pConnectionInfo[i].address_type = NDASCOMM_CONNECTION_INFO_TYPE_ADDR_LPX;
pConnectionInfo[i].login_type = NDASCOMM_LOGIN_TYPE_NORMAL;
pConnectionInfo[i].UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
pConnectionInfo[i].bWriteAccess = TRUE;
pConnectionInfo[i].ui64OEMCode = NULL;
pConnectionInfo[i].bSupervisor = FALSE;
pConnectionInfo[i].protocol = NDASCOMM_TRANSPORT_LPX;
CopyMemory(pConnectionInfo[i].AddressLPX,
unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
LPXADDR_NODE_LENGTH);
}
BindResult = NdasOpBind(NUMBER_MIGRATE_DISK, pConnectionInfo, NMT_RAID1);
WTL :: CString strMsg;
if(NUMBER_MIGRATE_DISK == BindResult)
{
strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_SUCCESS);
WTL::CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
MessageBox(
::GetFocus(),
strMsg,
strTitle,
MB_OK|MB_ICONINFORMATION
);
}
else
{
DWORD dwLastError = ::GetLastError();
switch(dwLastError)
{
case NDASCOMM_ERROR_RW_USER_EXIST:
case NDASOP_ERROR_ALREADY_USED:
case NDASOP_ERROR_DEVICE_FAIL:
//.........这里部分代码省略.........
示例2: HixChangeNotify
void CDiskPropertyPage1::OnMigrate(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
UINT32 BindResult;
CDiskObjectPtr disk = GetParentSheet()->GetDiskObject();
NDAS_CONNECTION_INFO pConnectionInfo[NUMBER_MIGRATE_DISK];
UINT32 i;
WTL::CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
// Find aggregation root
if (NUMBER_MIGRATE_DISK != disk->GetDiskCount())
{
WTL::CString strMsg;
strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_DISK_NOT_EXIST );
MessageBox(
strMsg,
strTitle,
MB_OK | MB_ICONWARNING
);
return;
}
WTL::CString strConfirmMsg;
strConfirmMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_CONFIRM );
if ( IDYES != MessageBox(
strConfirmMsg,
strTitle,
MB_YESNO | MB_ICONWARNING
)
)
{
return;
}
if ( !disk->CanAccessExclusive() )
{
WTL::CString strMsg;
strMsg.LoadString( IDS_DISKPROPERTYPAGE_MIGRATE_ACCESS_FAIL );
MessageBox(
strMsg,
strTitle,
MB_OK | MB_ICONWARNING
);
return;
}
CDiskObjectCompositePtr pDiskObjectComposite =
boost::dynamic_pointer_cast<CDiskObjectComposite>(disk);
CDiskObjectComposite::const_iterator itr;
for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
{
CUnitDiskObjectPtr unitDisk =
boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
pConnectionInfo[i].type = NDAS_CONNECTION_INFO_TYPE_MAC_ADDRESS;
pConnectionInfo[i].UnitNo = unitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
pConnectionInfo[i].bWriteAccess = TRUE;
pConnectionInfo[i].ui64OEMCode = NULL;
pConnectionInfo[i].protocol = IPPROTO_LPXTCP;
CopyMemory(pConnectionInfo[i].MacAddress,
unitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
LPXADDR_NODE_LENGTH);
}
BindResult = NdasOpBind(NUMBER_MIGRATE_DISK, pConnectionInfo, NMT_RAID1);
WTL :: CString strMsg;
if(NUMBER_MIGRATE_DISK == BindResult)
{
strMsg.LoadString(IDS_DISKPROPERTYPAGE_MIGRATE_SUCCESS);
WTL::CString strTitle;
strTitle.LoadString(IDS_APPLICATION);
MessageBox(
strMsg,
strTitle,
MB_OK|MB_ICONINFORMATION
);
GetDlgItem(IDC_TEXT_MIGRATE).ShowWindow( SW_HIDE );
GetDlgItem(IDC_BTN_MIGRATE).ShowWindow( SW_HIDE );
GetDlgItem(IDC_ST_MIGRATE).ShowWindow( SW_HIDE );
}
else
{
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
for (itr = pDiskObjectComposite->begin(), i = 0; itr != pDiskObjectComposite->end(); ++itr, ++i)
{
CUnitDiskObjectPtr unitDisk =
boost::dynamic_pointer_cast<CUnitDiskObject>(*itr);
if(BindResult == i)
//.........这里部分代码省略.........