Hmm ok, so now I do
ManagedObjectReference ^ vmmor = svcutil->GetDecendentMoRef(nullptr, "VirtualMachine", vmname);
And afterwards vmmor->Value contains the moref.
Does vmxSpec string always have to be "moref=vm-{number}"? Because, when I connect to ESXi directly, it returns a number only, like "5". When I ask through vcenter, I get "vm-7". Do I have to add the "vm-" in front myself in the ESXi-direct case or does the string have to be "moref=5" in that case?
Apart from that, when I call VixDiskLib_PrepareForAccess() through vcenter with moref=vm-7 it returns 0 and not 1 anymore. For direct connect to esxi with moref=vm-5 it still results in 20. Is that supposed to be like that?