我在我的項目中使用 VirtualBox 和 Virtual Box API Microsoft Com C++。它是 VirtualBox 6.0.6 軟件開發工具包 (SDK) 和 VirtualBox 6.0.6 平臺包。我有個問題。我想恢復早期創建的快照系統,但程序顯示錯誤。我的代碼與評論:HRESULT rc; IVirtualBoxClient *virtualBoxClient = nullptr; IVirtualBox *virtualBox = nullptr; IMachine *machine = nullptr; ISession *session = nullptr; IProgress *progress = nullptr; ISnapshot* snapshot = nullptr; BSTR sessiontype = SysAllocString(L"gui"); BSTR machineName = SysAllocString(L"Win7x64"); HRESULT rc = CoCreateInstance(CLSID_VirtualBoxClient, NULL, CLSCTX_INPROC_SERVER, IID_IVirtualBoxClient, (void**)&virtualBoxClient); rc = virtualBoxClient->get_VirtualBox(&virtualBox); // looking for a machine with a name Win7x64 rc = virtualBox->FindMachine(machineName, &machine); // create a session object rc = CoCreateInstance(CLSID_Session, NULL, CLSCTX_INPROC_SERVER, IID_ISession, (void**)&session); if (!SUCCEEDED(rc)) { printf("Error creating Session instance! rc = 0x%x\n", rc); break; } // block the machine machine->LockMachine(session, LockType::LockType_Shared); // the name of the snapshot system BSTR snapshotUUID = SysAllocString(L"Win7_test_snapshot"); // looking for a snapshot system rc = machine->FindSnapshot(snapshotUUID, &snapshot); // recover snapshot. ERROR: variable rc - E_NOTIMPL Not implemented. rc = machine->RestoreSnapshot(snapshot, &progress); printf("Starting VM, please wait ...\n"); //waiting for the end of the operation. Abnormal termination- progress == nullptr ! rc = progress->WaitForCompletion(-1); // unlocking the machine rc = session->UnlockMachine(); if (!SUCCEEDED(rc)) { printf("Error restore state machine!\n"); break; }此外,我創建了一個簡單的 C# 應用程序,并在那里得到了完全相同的錯誤。怎么了?這是錯誤的API?我什至多次更改操作系統(虛擬):你能幫我嗎,如何修復調用方法錯誤“RestoreSnapshot - E_NOTIMPL Not implemented”或者如何正確恢復系統快照?謝謝你。PS:我在官方論壇上問過這個問題,沒人幫我。
在 Virtual Box 中還原虛擬機快照時出錯
慕田峪7331174
2022-12-31 11:39:09