日期:2014-05-17  浏览次数:21006 次

VixVMware API函数出错
程序如下:
  VixHandle hostHandle = VIX_INVALID_HANDLE;
  VixHandle jobHandle = VIX_INVALID_HANDLE;
  VixHandle vmHandle = VIX_INVALID_HANDLE;
VixHandle powHandle = VIX_INVALID_HANDLE;
VixHandle loginHandle = VIX_INVALID_HANDLE;
jobHandle = VixHost_Connect(VIX_API_VERSION, VIX_SERVICEPROVIDER_VMWARE_WORKSTATION, NULL, 0, NULL, NULL, 0, VIX_INVALID_HANDLE, NULL, NULL);
VixError err = VixJob_Wait(jobHandle, VIX_PROPERTY_JOB_RESULT_HANDLE, &hostHandle, VIX_PROPERTY_NONE);
if (VIX_OK != err)
{
return ;
}
Vix_ReleaseHandle(jobHandle);
  jobHandle = VIX_INVALID_HANDLE; 
jobHandle = VixVM_Open(hostHandle, "F:\\vmware\\Windows 7.vmx", NULL, NULL);
err = VixJob_Wait(jobHandle, VIX_PROPERTY_JOB_RESULT_HANDLE, &vmHandle, VIX_PROPERTY_NONE);
if(VIX_OK != err)
{
return ;
}
Vix_ReleaseHandle(jobHandle);
  jobHandle = VIX_INVALID_HANDLE; 
jobHandle = VixVM_PowerOn(vmHandle, 0, VIX_INVALID_HANDLE, NULL, NULL);
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);
if(VIX_OK != err)
{
return ;
}
Vix_ReleaseHandle(jobHandle);
jobHandle = VixVM_WaitForToolsInGuest(vmHandle, 300, NULL, NULL);
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);
if(VIX_OK != err)
{
return ;
}
Vix_ReleaseHandle(jobHandle);

jobHandle = VixVM_LoginInGuest(vmHandle, "123456", "123456", 0, NULL, NULL);
err = VixJob_Wait(jobHandle, VIX_PROPERTY_NONE);
if(VIX_OK != err)
{
return ;
}
 VixVM_LoginInGuest函数失败,错误代码为3015.求指教.

------解决方案--------------------
我之间也出现过这样的错误,那时候我虚拟机的操作系统是Win7,后来改成XP就可以了,希望能帮到你...
------解决方案--------------------
会是字符的问题吗?API一般使用Unicode字符!

如:VixVM_CopyFileFromHostToGuest(vmHandle, (char*)lpFile ,"C:\\1.exe", 0, VIX_INVALID_HANDLE, NULL, NULL);


改为:VixVM_CopyFileFromHostToGuest(vmHandle, (char*)lpFile ,L"C:\\1.exe", 0, VIX_INVALID_HANDLE, NULL, NULL);

------解决方案--------------------
错误27是VIX_E_INVALID_UTF8_STRING,出现这个错误是因为路径里面出现了中文...