本文整理汇总了C++中ComPtr::COMSETTER方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::COMSETTER方法的具体用法?C++ ComPtr::COMSETTER怎么用?C++ ComPtr::COMSETTER使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComPtr
的用法示例。
在下文中一共展示了ComPtr::COMSETTER方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
// fill in remaining slots with null framebuffers
for (uScreenId = 0; uScreenId < cMonitors; uScreenId++)
{
ComPtr<IFramebuffer> fb;
LONG xOrigin, yOrigin;
HRESULT hrc2 = display->GetFramebuffer(uScreenId,
fb.asOutParam(),
&xOrigin, &yOrigin);
if (hrc2 == S_OK && fb.isNull())
{
NullFB *pNullFB = new NullFB();
pNullFB->AddRef();
pNullFB->init();
display->SetFramebuffer(uScreenId, pNullFB);
}
}
/* get the machine debugger (isn't necessarily available) */
ComPtr <IMachineDebugger> machineDebugger;
console->COMGETTER(Debugger)(machineDebugger.asOutParam());
if (machineDebugger)
{
Log(("Machine debugger available!\n"));
}
if (fRawR0 != ~0U)
{
if (!machineDebugger)
{
RTPrintf("Error: No debugger object; -%srawr0 cannot be executed!\n", fRawR0 ? "" : "no");
break;
}
machineDebugger->COMSETTER(RecompileSupervisor)(!fRawR0);
}
if (fRawR3 != ~0U)
{
if (!machineDebugger)
{
RTPrintf("Error: No debugger object; -%srawr3 cannot be executed!\n", fRawR3 ? "" : "no");
break;
}
machineDebugger->COMSETTER(RecompileUser)(!fRawR3);
}
if (fPATM != ~0U)
{
if (!machineDebugger)
{
RTPrintf("Error: No debugger object; -%spatm cannot be executed!\n", fPATM ? "" : "no");
break;
}
machineDebugger->COMSETTER(PATMEnabled)(fPATM);
}
if (fCSAM != ~0U)
{
if (!machineDebugger)
{
RTPrintf("Error: No debugger object; -%scsam cannot be executed!\n", fCSAM ? "" : "no");
break;
}
machineDebugger->COMSETTER(CSAMEnabled)(fCSAM);
}
/* initialize global references */
gConsole = console;
gEventQ = com::EventQueue::getMainEventQueue();
示例2: handleSnapshot
//.........这里部分代码省略.........
}
rc = showProgress(pProgress);
CHECK_PROGRESS_ERROR(pProgress, ("Snapshot operation failed"));
}
else if (!strcmp(a->argv[1], "edit"))
{
if (a->argc < 3)
{
errorSyntax(USAGE_SNAPSHOT, "Missing snapshot name");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> snapshot;
if ( !strcmp(a->argv[2], "--current")
|| !strcmp(a->argv[2], "-current"))
{
CHECK_ERROR_BREAK(ptrMachine, COMGETTER(CurrentSnapshot)(snapshot.asOutParam()));
}
else
{
CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
snapshot.asOutParam()));
}
/* parse options */
for (int i = 3; i < a->argc; i++)
{
if ( !strcmp(a->argv[i], "--name")
|| !strcmp(a->argv[i], "-name")
|| !strcmp(a->argv[i], "-newname"))
{
if (a->argc <= i + 1)
{
errorArgument("Missing argument to '%s'", a->argv[i]);
rc = E_FAIL;
break;
}
i++;
snapshot->COMSETTER(Name)(Bstr(a->argv[i]).raw());
}
else if ( !strcmp(a->argv[i], "--description")
|| !strcmp(a->argv[i], "-description")
|| !strcmp(a->argv[i], "-newdesc"))
{
if (a->argc <= i + 1)
{
errorArgument("Missing argument to '%s'", a->argv[i]);
rc = E_FAIL;
break;
}
i++;
snapshot->COMSETTER(Description)(Bstr(a->argv[i]).raw());
}
else
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str());
rc = E_FAIL;
break;
}
}
}
else if (!strcmp(a->argv[1], "showvminfo"))
{
/* exactly one parameter: snapshot name */
if (a->argc != 3)
{
errorSyntax(USAGE_SNAPSHOT, "Expecting snapshot name only");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> snapshot;
CHECK_ERROR_BREAK(ptrMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
snapshot.asOutParam()));
/* get the machine of the given snapshot */
ComPtr<IMachine> ptrMachine2;
snapshot->COMGETTER(Machine)(ptrMachine2.asOutParam());
showVMInfo(a->virtualBox, ptrMachine2, VMINFO_NONE, console);
}
else if (!strcmp(a->argv[1], "list"))
rc = handleSnapshotList(a, ptrMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
else if (!strcmp(a->argv[1], "dump")) // undocumented parameter to debug snapshot info
DumpSnapshot(ptrMachine);
else
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[1]).c_str());
rc = E_FAIL;
}
} while (0);
a->session->UnlockMachine();
return SUCCEEDED(rc) ? 0 : 1;
}
示例3: handleSnapshot
//.........这里部分代码省略.........
else if (!strcmp(a->argv[1], "edit"))
{
if (a->argc < 3)
{
errorSyntax(USAGE_SNAPSHOT, "Missing snapshot name");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> pSnapshot;
if ( !strcmp(a->argv[2], "--current")
|| !strcmp(a->argv[2], "-current"))
{
CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
if (pSnapshot.isNull())
{
RTPrintf("This machine does not have any snapshots\n");
return RTEXITCODE_FAILURE;
}
}
else
{
CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
pSnapshot.asOutParam()));
}
/* parse options */
for (int i = 3; i < a->argc; i++)
{
if ( !strcmp(a->argv[i], "--name")
|| !strcmp(a->argv[i], "-name")
|| !strcmp(a->argv[i], "-newname"))
{
if (a->argc <= i + 1)
{
errorArgument("Missing argument to '%s'", a->argv[i]);
rc = E_FAIL;
break;
}
i++;
pSnapshot->COMSETTER(Name)(Bstr(a->argv[i]).raw());
}
else if ( !strcmp(a->argv[i], "--description")
|| !strcmp(a->argv[i], "-description")
|| !strcmp(a->argv[i], "-newdesc"))
{
if (a->argc <= i + 1)
{
errorArgument("Missing argument to '%s'", a->argv[i]);
rc = E_FAIL;
break;
}
i++;
pSnapshot->COMSETTER(Description)(Bstr(a->argv[i]).raw());
}
else
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[i]).c_str());
rc = E_FAIL;
break;
}
}
}
else if (!strcmp(a->argv[1], "showvminfo"))
{
/* exactly one parameter: snapshot name */
if (a->argc != 3)
{
errorSyntax(USAGE_SNAPSHOT, "Expecting snapshot name only");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> pSnapshot;
CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
pSnapshot.asOutParam()));
/* get the machine of the given snapshot */
ComPtr<IMachine> pMachine2;
pSnapshot->COMGETTER(Machine)(pMachine2.asOutParam());
showVMInfo(a->virtualBox, pMachine2, NULL, VMINFO_NONE);
}
else if (!strcmp(a->argv[1], "list"))
rc = handleSnapshotList(a, sessionMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
else if (!strcmp(a->argv[1], "dump")) // undocumented parameter to debug snapshot info
DumpSnapshot(sessionMachine);
else
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(a->argv[1]).c_str());
rc = E_FAIL;
}
} while (0);
a->session->UnlockMachine();
return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
}
示例4: handleControlVM
int handleControlVM(HandlerArg *a)
{
using namespace com;
HRESULT rc;
if (a->argc < 2)
return errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
/* try to find the given machine */
ComPtr <IMachine> machine;
CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
machine.asOutParam()));
if (FAILED(rc))
return 1;
/* open a session for the VM */
CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Shared), 1);
do
{
/* get the associated console */
ComPtr<IConsole> console;
CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));
/* ... and session machine */
ComPtr<IMachine> sessionMachine;
CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
/* which command? */
if (!strcmp(a->argv[1], "pause"))
{
CHECK_ERROR_BREAK(console, Pause());
}
else if (!strcmp(a->argv[1], "resume"))
{
CHECK_ERROR_BREAK(console, Resume());
}
else if (!strcmp(a->argv[1], "reset"))
{
CHECK_ERROR_BREAK(console, Reset());
}
else if (!strcmp(a->argv[1], "unplugcpu"))
{
if (a->argc <= 1 + 1)
{
errorArgument("Missing argument to '%s'. Expected CPU number.", a->argv[1]);
rc = E_FAIL;
break;
}
unsigned n = parseNum(a->argv[2], 32, "CPU");
CHECK_ERROR_BREAK(sessionMachine, HotUnplugCPU(n));
}
else if (!strcmp(a->argv[1], "plugcpu"))
{
if (a->argc <= 1 + 1)
{
errorArgument("Missing argument to '%s'. Expected CPU number.", a->argv[1]);
rc = E_FAIL;
break;
}
unsigned n = parseNum(a->argv[2], 32, "CPU");
CHECK_ERROR_BREAK(sessionMachine, HotPlugCPU(n));
}
else if (!strcmp(a->argv[1], "cpuexecutioncap"))
{
if (a->argc <= 1 + 1)
{
errorArgument("Missing argument to '%s'. Expected execution cap number.", a->argv[1]);
rc = E_FAIL;
break;
}
unsigned n = parseNum(a->argv[2], 100, "ExecutionCap");
CHECK_ERROR_BREAK(sessionMachine, COMSETTER(CPUExecutionCap)(n));
}
else if (!strcmp(a->argv[1], "clipboard"))
{
if (a->argc <= 1 + 1)
{
errorArgument("Missing argument to '%s'. Expected clipboard mode.", a->argv[1]);
rc = E_FAIL;
break;
}
ClipboardMode_T mode;
if (!strcmp(a->argv[2], "disabled"))
mode = ClipboardMode_Disabled;
else if (!strcmp(a->argv[2], "hosttoguest"))
mode = ClipboardMode_HostToGuest;
else if (!strcmp(a->argv[2], "guesttohost"))
mode = ClipboardMode_GuestToHost;
else if (!strcmp(a->argv[2], "bidirectional"))
mode = ClipboardMode_Bidirectional;
else
{
errorArgument("Invalid '%s' argument '%s'.", a->argv[1], a->argv[2]);
//.........这里部分代码省略.........
示例5: if
STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent)
{
switch (aType)
{
case VBoxEventType_OnGuestPropertyChanged:
{
ComPtr<IGuestPropertyChangedEvent> gpcev = aEvent;
Assert(gpcev);
Bstr aKey;
gpcev->COMGETTER(Name)(aKey.asOutParam());
if (aKey == Bstr("/VirtualBox/GuestInfo/OS/NoLoggedInUsers"))
{
/* Check if this is our machine and the "disconnect on logout feature" is enabled. */
BOOL fProcessDisconnectOnGuestLogout = FALSE;
ComPtr <IMachine> machine;
HRESULT hrc = S_OK;
if (gConsole)
{
hrc = gConsole->COMGETTER(Machine)(machine.asOutParam());
if (SUCCEEDED(hrc) && machine)
{
Bstr id, machineId;
hrc = machine->COMGETTER(Id)(id.asOutParam());
gpcev->COMGETTER(MachineId)(machineId.asOutParam());
if (id == machineId)
{
Bstr value1;
hrc = machine->GetExtraData(Bstr("VRDP/DisconnectOnGuestLogout").raw(),
value1.asOutParam());
if (SUCCEEDED(hrc) && value1 == "1")
{
fProcessDisconnectOnGuestLogout = TRUE;
}
}
}
}
if (fProcessDisconnectOnGuestLogout)
{
bool fDropConnection = false;
Bstr value;
gpcev->COMGETTER(Value)(value.asOutParam());
Utf8Str utf8Value = value;
if (!mfNoLoggedInUsers) /* Only if the property really changes. */
{
if ( utf8Value == "true"
/* Guest property got deleted due to reset,
* so it has no value anymore. */
|| utf8Value.isEmpty())
{
mfNoLoggedInUsers = true;
fDropConnection = true;
}
}
else if (utf8Value == "false")
mfNoLoggedInUsers = false;
/* Guest property got deleted due to reset,
* take the shortcut without touching the mfNoLoggedInUsers
* state. */
else if (utf8Value.isEmpty())
fDropConnection = true;
if (fDropConnection)
{
/* If there is a connection, drop it. */
ComPtr<IVRDEServerInfo> info;
hrc = gConsole->COMGETTER(VRDEServerInfo)(info.asOutParam());
if (SUCCEEDED(hrc) && info)
{
ULONG cClients = 0;
hrc = info->COMGETTER(NumberOfClients)(&cClients);
if (SUCCEEDED(hrc) && cClients > 0)
{
ComPtr <IVRDEServer> vrdeServer;
hrc = machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
if (SUCCEEDED(hrc) && vrdeServer)
{
LogRel(("VRDE: the guest user has logged out, disconnecting remote clients.\n"));
vrdeServer->COMSETTER(Enabled)(FALSE);
vrdeServer->COMSETTER(Enabled)(TRUE);
}
}
}
}
}
}
break;
}
default:
AssertFailed();
}
return S_OK;
}