您的位置:首页 > 其它

Common Tasks :Connecting to the Local Host as the Current User

2012-10-19 11:17 501 查看
This option allows you to connect a Vix client to a VMware product running on the same host. You can use this option with a host running either VMware Workstation or VMware server. To allow the client to connect to either product without modifying your
code, specify VIX_SERVICEPROVIDER_DEFAULT as the value of the hostType parameter.

This option maximizes portability. You can run the client on any host machine, without limiting yourself to a particular user account and without having to specify a user account
at run time. However, you must be sure that the current user has appropriate permissions to use one or more virtual machines on the local host.

Example 3-3.

#include "vix.h"
 
int main(int argc, char * argv[])
{
VixHandle hostHandle = VIX_INVALID_HANDLE;
VixHandle jobHandle = VIX_INVALID_HANDLE;
VixError err;
 
// Connect as current user on local host.
jobHandle = VixHost_Connect(VIX_API_VERSION,
VIX_SERVICEPROVIDER_VMWARE_WORKSTATION,
NULL, // hostName
0, // hostPort
NULL, // userName
NULL, // password,
0, // options
VIX_INVALID_HANDLE, // propertyListHandle
NULL, // callbackProc
NULL); // clientData

err = VixJob_Wait(jobHandle,
VIX_PROPERTY_JOB_RESULT_HANDLE,
&hostHandle,
VIX_PROPERTY_NONE);
if (VIX_OK != err) {
// Handle the error...
goto abort;
}

Vix_ReleaseHandle(jobHandle);
jobHandle = VIX_INVALID_HANDLE;
// Other code goes here...
 
abort:
VixHost_Disconnect(hostHandle);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐