Ejemplo n.º 1
0
        /// <summary>
        /// Creates a host handle
        /// </summary>
        /// <returns>true if succeeded, otherwise false</returns>
        public bool Connect(string hostName, string userName, string password)
        {
            int hostType = string.IsNullOrEmpty(hostName) ?
                           VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION :
                           VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER;

            int vixVersion = VixCOM.Constants.VIX_API_VERSION;

            vixVersion = 1; // Bugfix: http://communities.vmware.com/message/649925#649925

            //VixCOM.IJob jobHandle = vixLib.Connect(vixVersion, hostType, hostName, 0, userName, password, 0, null,  null);

            // for use with player: http://www.vmware.com/pdf/vix180_player_technote.pdf
            VixCOM.IJob jobHandle = vixLib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_PLAYER, null, 0, null, null, VixCOM.Constants.VIX_INVALID_HANDLE, null, null);

            int[] propertyIds = new int[1] {
                VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE
            };
            object results = new object();

            m_vixError = jobHandle.Wait(propertyIds, ref results);

            if (m_vixError == VixCOM.Constants.VIX_OK)
            {
                object[] objectArray = (object[])results;
                m_hostHandle = (VixCOM.IHost)objectArray[0];
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a host handle
        /// </summary>
        /// <returns>true if succeeded, otherwise false</returns>
        public bool Connect(string hostName, string userName, string password, int serviceProvider)
        {
            int hostType = -1;

            // Edited by Mitchell Lutz
            if (serviceProvider == 1)
            {
                hostType = VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION;
            }
            else if (serviceProvider == 2)
            {
                hostType = VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER;
            }
            //int hostType = string.IsNullOrEmpty(hostName) ?
            //    VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_WORKSTATION :
            //    VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER;

            int vixVersion = VixCOM.Constants.VIX_API_VERSION;

            vixVersion = 1; // Bugfix: http://communities.vmware.com/message/649925#649925

            VixCOM.IJob jobHandle = vixLib.Connect(vixVersion,
                                                   hostType, hostName, 0, userName, password, 0, null, null);

            int[] propertyIds = new int[1] {
                VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE
            };
            object results = new object();

            m_vixError = jobHandle.Wait(propertyIds, ref results);

            if (m_vixError == VixCOM.Constants.VIX_OK)
            {
                object[] objectArray = (object[])results;
                m_hostHandle = (VixCOM.IHost)objectArray[0];
                return(true);
            }

            return(false);
        }