我在我的項(xiàng)目中使用 VirtualBox 和 Virtual Box API Microsoft Com C++。它是 VirtualBox 6.0.6 軟件開發(fā)工具包 (SDK) 和 VirtualBox 6.0.6 平臺(tái)包。我有個(gè)問題。我想恢復(fù)早期創(chuàng)建的快照系統(tǒng),但程序顯示錯(cuò)誤。我的代碼與評(píng)論: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; }此外,我創(chuàng)建了一個(gè)簡(jiǎn)單的 C# 應(yīng)用程序,并在那里得到了完全相同的錯(cuò)誤。怎么了?這是錯(cuò)誤的API?我什至多次更改操作系統(tǒng)(虛擬):你能幫我嗎,如何修復(fù)調(diào)用方法錯(cuò)誤“RestoreSnapshot - E_NOTIMPL Not implemented”或者如何正確恢復(fù)系統(tǒng)快照?謝謝你。PS:我在官方論壇上問過這個(gè)問題,沒人幫我。
在 Virtual Box 中還原虛擬機(jī)快照時(shí)出錯(cuò)
慕田峪7331174
2022-12-31 11:39:09