本文整理汇总了C++中ActionStatus::Successful方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionStatus::Successful方法的具体用法?C++ ActionStatus::Successful怎么用?C++ ActionStatus::Successful使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionStatus
的用法示例。
在下文中一共展示了ActionStatus::Successful方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveResourceToFile
static ActionStatus SaveResourceToFile(const String &filePath, LPCTSTR lpResType, DWORD dwID)
{
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hRes = FindResource(hModule, MAKEINTRESOURCE(dwID), lpResType);
if (!hRes)
return MAKE_STATUS(ActionStatus::FailFromLastError());
DWORD len = SizeofResource(hModule, hRes);
if (!len)
return MAKE_STATUS(ActionStatus::FailFromLastError());
HGLOBAL hResObj = LoadResource(hModule, hRes);
if (!hResObj)
return MAKE_STATUS(ActionStatus::FailFromLastError());
PVOID p = LockResource(hResObj);
if (!p)
return MAKE_STATUS(ActionStatus::FailFromLastError());
ActionStatus st;
File file(filePath, FileModes::CreateOrTruncateRW, &st);
if (!st.Successful())
return st;
file.Write(p, len, &st);
if (!st.Successful())
return st;
return MAKE_STATUS(Success);
}
示例2: EnableCustomKD
virtual ActionStatus EnableCustomKD(LPCWSTR pCustomKDName)
{
if (!pCustomKDName)
return MAKE_STATUS(InvalidParameter);
ActionStatus st = m_Object.SetElement(BcdOSLoaderString_DbgTransportPath, pCustomKDName);
if (!st.Successful())
return st;
st = m_Object.SetElement(BcdLibraryBoolean_AllowPrereleaseSignatures, true);
ActionStatus st2 = m_Object.SetElement(BcdOSLoaderBoolean_AllowPrereleaseSignatures, true);
if (!st.Successful() && !st2.Successful())
return st;
return m_Object.SetElement(BcdOSLoaderBoolean_KernelDebuggerEnabled, true);
}
示例3: TryLaunchVVMON
ActionStatus TryLaunchVVMON(const String &exePath, bool WaitForPipeAvailable = true)
{
const int kVMMONStartTimeout = 10000;
ActionStatus st;
BazisLib::Win32::Process vmmon(exePath.c_str(), true, &st);
if (!st.Successful())
return st;
if (!WaitForPipeAvailable)
return MAKE_STATUS(Success);
DateTime start = DateTime::Now();
for (;;)
{
Sleep(100);
if ((DateTime::Now() - start).GetTotalMilliseconds() >= kVMMONStartTimeout)
return MAKE_STATUS(UnknownError);
ULONGLONG result = 0;
if (TryCallOutprocClientUsingVMMON(kQueryVersion, 0, NULL, 0, &result).Successful())
break;
if (!vmmon.IsRunning())
return MAKE_STATUS(UnknownError);
}
return MAKE_STATUS(Success);
}
示例4: Initialize
HRESULT STDMETHODCALLTYPE CDriveContextMenu::Initialize(/* [unique][in] */ __in_opt PCIDLIST_ABSOLUTE pidlFolder, /* [unique][in] */ __in_opt IDataObject *pdtobj, /* [unique][in] */ __in_opt HKEY hkeyProgID)
{
WINCDEMU_LOG_LINE(L"CDriveContextMenu::Initialize()");
HRESULT hR = ContextMenuBase::Initialize(pidlFolder, pdtobj, hkeyProgID);
if (!SUCCEEDED(hR))
return hR;
if (m_FileName.length() == 3 && m_FileName[1] == ':' && GetDriveType(m_FileName.c_str()) == DRIVE_CDROM)
{
m_bIsOpticalDrive = true;
if (m_FileName.length() == 3 && m_FileName[1] == ':' && m_FileName[2] == '\\')
{
wchar_t wszPath [] = L"\\\\.\\?:";
wszPath[4] = m_FileName[0];
ActionStatus status;
VirtualDriveClient clt(wszPath, &status);
m_bIsWinCDEmuDrive = status.Successful();
}
}
WINCDEMU_LOG_LINE(L"CDriveContextMenu::Initialize(): isDrive = %d, isWinCDEmu = %d", m_bIsOpticalDrive, m_bIsWinCDEmuDrive);
return S_OK;
}
示例5: InstallRootEnumeratedDriver
LRESULT CMainDlg::OnBnClickedButton1(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
{
int idx = m_ComboBox.GetCurSel();
if (idx >= 0 && idx < m_Projects.size())
{
ActionStatus st = InstallRootEnumeratedDriver((String(L"root\\") + m_Projects[idx].SampleName).c_str(), m_Projects[idx].INFFile.c_str());
if (!st.Successful())
MessageBox(String::sFormat(L"Cannot install driver: %s", st.GetErrorText().c_str()).c_str(), NULL, MB_ICONERROR);
OnCbnSelchangeCombo1(0,0,0,bHandled);
}
return 0;
}
示例6: OnCbnSelchangeCdreadspeed
LRESULT CISOProgressDialog::OnCbnSelchangeCdreadspeed(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
size_t idx = m_cbReadSpeeds.GetCurSel();
if (idx >= m_CDReadSpeeds.size())
return 0;
int speed = m_CDReadSpeeds[idx];
ActionStatus st = SetCDReadSpeed(m_pReader->GetSourcePath(), speed);
if (!st.Successful())
MessageBox(st.GetMostInformativeText().c_str(), NULL, MB_ICONERROR);
m_pReader->ResetRemainingTimeCalculation();
return 0;
}
示例7: MountNewImage
BazisLib::ActionStatus VirtualDriveClient::MountNewImage(const wchar_t *pwszImage, unsigned timeout)
{
ActionStatus status;
ULONGLONG hWait = 0;
m_Drive.DeviceIoControl(IOCTL_VDEV_MOUNT_IMAGE, pwszImage, pwszImage ? ((wcslen(pwszImage) + 1) * sizeof(wchar_t)) : 0, &hWait, timeout ? sizeof(hWait) : 0, &status);
if (!status.Successful())
return status;
if (timeout && hWait)
{
if (WaitForSingleObject(reinterpret_cast<HANDLE>(hWait), timeout) != WAIT_OBJECT_0)
return MAKE_STATUS(TimeoutExpired);
}
return status;
}
示例8: BootEntry
virtual ManagedPointer<AIBootConfigurationEntry> CopyEntry(const ConstManagedPointer<AIBootConfigurationEntry> &pEntry, bool AddToSelectionList = true, ActionStatus *pStatus = NULL)
{
if (!pEntry)
{
ASSIGN_STATUS(pStatus, InvalidParameter);
return NULL;
}
ManagedPointer<BootEntry> pBootEntry = pEntry;
if (!pBootEntry->Valid())
{
ASSIGN_STATUS(pStatus, InvalidParameter);
return NULL;
}
BCDObject newObj = m_Store.CopyObject(pBootEntry->m_Object, pStatus);
if (!newObj.Valid())
{
ASSIGN_SUBSTATUS(pStatus, *pStatus, UnknownError);
return NULL;
}
if (AddToSelectionList)
{
BCDObject globalSettings = m_Store.GetFirstObjectOfType(BCDObject::GlobalSettings);
if (!globalSettings.Valid())
{
ASSIGN_STATUS(pStatus, UnknownError);
return NULL;
}
BCDObjectList selectionList = globalSettings.GetElement(BcdBootMgrObjectList_DisplayOrder).GetObjectList();
if (!selectionList.Valid())
{
ASSIGN_STATUS(pStatus, UnknownError);
return NULL;
}
ActionStatus st = selectionList.InsertObject(newObj);
if (!st.Successful())
{
ASSIGN_SUBSTATUS(pStatus, st, UnknownError);
return NULL;
}
}
ASSIGN_STATUS(pStatus, Success);
return new BootEntry(newObj);
}
示例9: CreateVirtualKDBootEntry
ActionStatus CreateVirtualKDBootEntry(bool CreateNewEntry, bool SetNewEntryDefault, LPCWSTR lpEntryName, unsigned Timeout)
{
ManagedPointer<AIBootConfigurationEditor> pEditor = CreateConfigurationEditor();
if (!pEditor)
return MAKE_STATUS(UnknownError);
bool alreadyInstalled = false;
ManagedPointer<AIBootConfigurationEntry> pEntry;
ActionStatus st = FindBestOSEntry(&pEntry, &alreadyInstalled, pEditor);
if (!st.Successful())
return st;
if (!pEntry)
return MAKE_STATUS(NotSupported);
if (CreateNewEntry && !alreadyInstalled)
pEntry = pEditor->CopyEntry(pEntry, true, &st);
if (!pEntry)
return MAKE_STATUS(NotSupported);
st = pEntry->EnableCustomKD(L"kdbazis.dll");
if (!st.Successful())
return COPY_STATUS(st);
if (!st.Successful())
return COPY_STATUS(st);
if (!pEntry)
return MAKE_STATUS(UnknownError);
if (lpEntryName)
{
st = pEntry->SetDescription(lpEntryName);
if (!st.Successful())
return COPY_STATUS(st);
}
if (SetNewEntryDefault)
{
st = pEditor->SetDefaultEntry(pEntry);
if (!st.Successful())
return COPY_STATUS(st);
}
if (Timeout != -1)
{
st = pEditor->SetTimeout(Timeout);
if (!st.Successful())
return COPY_STATUS(st);
}
return pEditor->FinishEditing();
}
示例10: WorkerThread
int BasicTCPServer::WorkerThread::ThreadBody()
{
InternetAddress addr;
TCPSocket sock;
ActionStatus st = m_pServer->m_Listener.Accept(&sock, &addr);
if (st.Successful() && sock.Valid())
{
m_pServer->m_ActiveThreadCount++;
WorkerThread *pThread = new WorkerThread(m_pServer);
if (!pThread || !pThread->Start())
delete pThread;
m_pServer->ConnectionHandler(sock, addr);
}
if (!--m_pServer->m_ActiveThreadCount)
m_pServer->m_LastThreadDone.Set();
return 0;
}
示例11: Call64BitKDCLIENT
ULONGLONG Call64BitKDCLIENT(KDClientCommand cmd, unsigned PID, LPWSTR lpStringResult, size_t StringSize)
{
ULONGLONG result = 0;
if (TryCallOutprocClientUsingVMMON(cmd, PID, lpStringResult, StringSize, &result).Successful())
return result;
if (TryCall64BitClientUsingRundll(cmd, PID, lpStringResult, StringSize, &result).Successful())
return result;
for (;;)
{
if (s_bDoNotSuggestLaunchingVMMON)
return -1;
s_bDoNotSuggestLaunchingVMMON = true;
TCHAR tszModule[MAX_PATH] = {0,};
GetModuleFileName(g_hThisDll, tszModule, __countof(tszModule));
String vmmonExe = Path::Combine(Path::GetDirectoryName(TempStrPointerWrapper(tszModule)), WOW64APIProvider::sIsWow64Process() ? _T("vmmon64.exe") : _T("vmmon.exe"));
if (File::Exists(vmmonExe))
{
switch(MessageBox(HWND_DESKTOP, _T("Failed to quesy VM information. This is most likely caused by insufficient privilege level. Do you want to start Virtual Machine monitor (VMMON) in Administrator mode to fix this problem?"), _T("VirtualKD"), MB_ICONQUESTION | MB_TOPMOST | MB_YESNO))
{
case IDYES:
break;
case IDNO:
return -1;
}
}
else
{
MessageBox(HWND_DESKTOP, _T("Failed to quesy VM information. This is most likely caused by insufficient privilege level. Running VMMON/VMMON64 will solve the problem."), _T("VirtualKD"), MB_ICONERROR | MB_TOPMOST | MB_OK);
return -1;
}
ActionStatus st = TryLaunchVVMON(vmmonExe);
if (!st.Successful())
{
MessageBox(HWND_DESKTOP, st.GetMostInformativeText().c_str(), _T("Failed to launch VMMON"), MB_ICONERROR | MB_TOPMOST | MB_OK);
return -1;
}
s_bDoNotSuggestLaunchingVMMON = false;
if (TryCallOutprocClientUsingVMMON(cmd, PID, lpStringResult, StringSize, &result).Successful())
return result;
}
return result;
}
示例12: FindBestOSEntry
ActionStatus FindBestOSEntry(ManagedPointer<AIBootConfigurationEntry> *ppEntry, bool *pbAlreadyInstalled, ManagedPointer<AIBootConfigurationEditor> pEditor)
{
ASSERT(ppEntry);
*ppEntry = NULL;
if (!pEditor)
pEditor = CreateConfigurationEditor();
if (!pEditor)
return MAKE_STATUS(UnknownError);
ActionStatus st = pEditor->StartEnumeration();
if (!st.Successful())
return st;
if (pbAlreadyInstalled)
*pbAlreadyInstalled = false;
ManagedPointer<AIBootConfigurationEntry> pEntry, pCurrentOSEntry;
while (pEntry = pEditor->GetNextEntry())
{
if (pEntry->IsCurrentOS())
{
if (!pCurrentOSEntry)
pCurrentOSEntry = pEntry;
if ((pEntry->GetDebuggerMode() == kdCustom) && (!pEntry->GetCustomKDName().icompare(_T("kdbazis.dll"))))
{
pCurrentOSEntry = pEntry;
if (pbAlreadyInstalled)
*pbAlreadyInstalled = true;
break;
}
}
}
*ppEntry = pCurrentOSEntry;
if (!pCurrentOSEntry)
return MAKE_STATUS(NotSupported);
return MAKE_STATUS(Success);
}
示例13: Start
ActionStatus BasicTCPServer::Start(unsigned PortNumber)
{
if (m_ActiveThreadCount)
return MAKE_STATUS(InvalidState);
ActionStatus st = m_Listener.Listen(PortNumber);
if (!st.Successful())
return st;
m_LastThreadDone.Reset();
m_ActiveThreadCount++;
WorkerThread *pThread = new WorkerThread(this);
if (!pThread)
return MAKE_STATUS(NoMemory);
if (!pThread->Start())
{
delete pThread;
m_ActiveThreadCount--;
return MAKE_STATUS(UnknownError);
}
return MAKE_STATUS(Success);
}
示例14: OnOK
LRESULT CMainDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
bool createNewEntry = false, setDefault = false, replaceKdcom = false;
String entryName, monitorLocation;
unsigned timeout = -1;
if (SendDlgItemMessage(IDC_SETDEFAULT, BM_GETCHECK) == BST_CHECKED)
setDefault = true, timeout = GetDlgItemInt(IDC_TIMEOUT);
if (SendDlgItemMessage(IDC_KDCOM, BM_GETCHECK) == BST_CHECKED)
replaceKdcom = true;
if (SendDlgItemMessage(IDC_NEWENTRY, BM_GETCHECK) == BST_CHECKED)
{
size_t len = ::GetWindowTextLength(GetDlgItem(IDC_ENTRYNAME));
entryName.SetLength(GetDlgItemText(IDC_ENTRYNAME, entryName.PreAllocate(len, false), len + 1));
createNewEntry = true;
}
else
{
entryName = m_ExistingEntryName;
if (SendDlgItemMessage(IDC_ADDSUFFIX, BM_GETCHECK) == BST_CHECKED)
entryName += _T(" [VirtualKD]");
}
#ifdef SUPPORT_VISUALDDK
if (SendDlgItemMessage(IDC_INSTALLVDDK, BM_GETCHECK) == BST_CHECKED)
{
size_t len = ::GetWindowTextLength(GetDlgItem(IDC_VDDKLOCATION));
monitorLocation.SetLength(GetDlgItemText(IDC_VDDKLOCATION, monitorLocation.PreAllocate(len, false), len + 1));
}
#endif
{
String fp = Path::Combine(Path::GetSpecialDirectoryLocation(dirSystem), replaceKdcom ? ConstString(_T("kdcom.dll")) : ConstString(_T("kdbazis.dll")));
#ifdef _WIN64
bool is64Bit = true;
#else
bool is64Bit = BazisLib::WOW64APIProvider::sIsWow64Process();
#endif
ActionStatus st;
{
WOW64FSRedirHolder holder;
if (replaceKdcom)
{
String kdcomBackup = Path::Combine(Path::GetSpecialDirectoryLocation(dirSystem), ConstString(_T("kdcom_old.dll")));
if (!File::Exists(kdcomBackup))
{
st = TakeOwnership(const_cast<LPTSTR>(String(fp).c_str()));
if (!st.Successful())
{
::MessageBox(HWND_DESKTOP,
String::sFormat(_T("Cannot replace owner on kdcom.dll: %s"), st.GetMostInformativeText().c_str()).c_str(),
NULL,
MB_ICONERROR);
return 0;
}
Win32::Security::TranslatedAcl dacl = File::GetDACLForPath(fp, &st);
if (!st.Successful())
{
::MessageBox(HWND_DESKTOP,
String::sFormat(_T("Cannot query permissions on kdcom.dll: %s"), st.GetMostInformativeText().c_str()).c_str(),
NULL,
MB_ICONERROR);
return 0;
}
dacl.AddAllowingAce(STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL, BazisLib::Win32::Security::Sid::CurrentUserSid());
st = File::SetDACLForPath(fp, dacl);
if (!st.Successful())
{
::MessageBox(HWND_DESKTOP,
String::sFormat(_T("Cannot set permissions on kdcom.dll: %s"), st.GetMostInformativeText().c_str()).c_str(),
NULL,
MB_ICONERROR);
return 0;
}
if (!MoveFile(fp.c_str(), kdcomBackup.c_str()))
{
::MessageBox(HWND_DESKTOP,
String::sFormat(_T("Cannot rename old kdcom.dll: %s"), MAKE_STATUS(ActionStatus::FromLastError()).GetMostInformativeText().c_str()).c_str(),
NULL,
MB_ICONERROR);
return 0;
}
}
}
st = SaveResourceToFile(fp, _T("KDVMDLL"), is64Bit ? IDR_KDVM64 : IDR_KDVM32);
}
if (!st.Successful())
{
::MessageBox(HWND_DESKTOP,
String::sFormat(_T("Cannot create KDBAZIS.DLL: %s"), st.GetMostInformativeText().c_str()).c_str(),
NULL,
MB_ICONERROR);
return 0;
//.........这里部分代码省略.........
示例15: OnTimer
LRESULT CISOProgressDialog::OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
extern bool AutorunErrorHandler(ActionStatus st);
BackgroundDriveReader::ProgressRecord progress = m_pReader->GetProgress();
unsigned progressVal = (unsigned)((progress.Done * kProgressRangeMax) / progress.Total);
if (progress.TotalBad)
{
if (m_pTaskbar)
m_pTaskbar->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
m_ProgressBar.SetPos((int)((progress.ProcessedBad * kProgressRangeMax) / progress.TotalBad));
SetDlgItemText(IDC_PROGRESSLINE, String::sFormat(_TR(IDS_BADSECTORPROGRESSFMT, "Re-reading bad sectors (%d/%d)"), (int)progress.ProcessedBad, (int)progress.TotalBad).c_str());
}
else
{
if (m_pTaskbar)
m_pTaskbar->SetProgressValue(m_hWnd, progress.Done, progress.Total);
m_ProgressBar.SetPos(progressVal);
unsigned badSectorCount = m_pReader->GetTotalBadSectorCount();
if (!badSectorCount)
{
bool remainingTimeAccurate = false;
TimeSpan remainingTime = m_pReader->GetEstimatedRemainingTime(&remainingTimeAccurate);
String label = String::sFormat(_TR(IDS_SPEEDSTATFMT, "Average read speed: %s/s"), RateCalculator::FormatByteCount(progress.BytesPerSecond).c_str());
if (remainingTimeAccurate && (remainingTime.GetTotalSeconds() > 3))
label += String::sFormat(_TR(IDS_REMAININGTIMESUFFIX, ", remaining time: %02d:%02d"), remainingTime.GetTotalMinutes(), remainingTime.GetSeconds());
SetDlgItemText(IDC_PROGRESSLINE, label.c_str());
}
else
SetDlgItemText(IDC_PROGRESSLINE, String::sFormat(_TR(IDS_BADSECTFMT, "Average read speed: %s/s, %d bad sector(s) found"), RateCalculator::FormatByteCount(progress.BytesPerSecond).c_str(), badSectorCount).c_str());
}
if (m_pReader->QueryStatus().GetErrorCode() != Pending)
{
KillTimer(0);
::EnableWindow(GetDlgItem(IDC_PAUSE), FALSE);
ActionStatus st = m_pReader->QueryStatus();
if (st.Successful())
{
FunctionThread ejectThread(&EjectDriveProc, (PVOID)m_pReader->GetSourcePath());
if (SendDlgItemMessage(IDC_EJECTDISC, BM_GETCHECK) == BST_CHECKED)
ejectThread.Start();
if (SendDlgItemMessage(IDC_OPENFOLDER, BM_GETCHECK) == BST_CHECKED)
Win32::Process(Path::GetDirectoryName(ConstString(m_pReader->GetImagePath())).c_str(), _T("open"));
if (SendDlgItemMessage(IDC_MOUNTISO, BM_GETCHECK) == BST_CHECKED)
{
wchar_t wszKernelPath[512];
if (!VirtualCDClient::Win32FileNameToKernelFileName(m_pReader->GetImagePath(), wszKernelPath, __countof(wszKernelPath)))
MessageBox(_TR(IDS_BADIMGFN, "Invalid image file name!"), NULL, MB_ICONERROR);
else
{
TCHAR tsz[3] = {0,};
if (m_cbLetters.GetLBTextLen(m_cbLetters.GetCurSel()) < _countof(tsz))
m_cbLetters.GetLBText(m_cbLetters.GetCurSel(), tsz);
VirtualCDClient().ConnectDisk(wszKernelPath, (char)(tsz[0]), 0, m_RegParams.DisableAutorun, false, AutorunErrorHandler);
}
}
ejectThread.Join();
if (SendDlgItemMessage(IDC_CLOSEWINDOW, BM_GETCHECK) == BST_CHECKED)
{
EndDialog(IDOK);
SaveParams();
}
else
{
SetDlgItemText(IDCANCEL, _TR(IDS_CLOSE, "Close"));
m_ProgressBar.SetPos(kProgressRangeMax);
::SetFocus(GetDlgItem(IDCANCEL));
MessageBox(_TR(IDS_ISOCREATED, "The ISO image has been created successfully"), _TR(IDS_INFORMATION, "Information"), MB_ICONINFORMATION);
}
}
else
{
if (st.GetErrorCode() != OperationAborted)
MessageBox(st.GetMostInformativeText().c_str(), NULL, MB_ICONERROR);
DeleteFile(m_pReader->GetImagePath());
EndDialog(IDNO);
}
}
return 0;
}