コード例 #1
0
        internal static string GetNamespacePath(IWbemPath wbemPath, int flags)
        {
            string empty = string.Empty;

            if (wbemPath != null)
            {
                uint num             = 0;
                int  namespaceCount_ = wbemPath.GetNamespaceCount_(out num);
                if (namespaceCount_ >= 0 && num > 0)
                {
                    int num1 = 0;
                    namespaceCount_ = wbemPath.GetText_(flags, out num1, null);
                    if (namespaceCount_ >= 0 && num1 > 0)
                    {
                        empty           = new string('0', num1 - 1);
                        namespaceCount_ = wbemPath.GetText_(flags, out num1, empty);
                    }
                }
                if (namespaceCount_ < 0 && namespaceCount_ != -2147217400)
                {
                    if (((long)namespaceCount_ & (long)-4096) != (long)-2147217408)
                    {
                        Marshal.ThrowExceptionForHR(namespaceCount_);
                    }
                    else
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)namespaceCount_);
                    }
                }
            }
            return(empty);
        }
コード例 #2
0
        internal static string GetNamespacePath(IWbemPath wbemPath, int flags)
        {
            string pszText = string.Empty;

            if (wbemPath != null)
            {
                uint puCount   = 0;
                int  errorCode = 0;
                errorCode = wbemPath.GetNamespaceCount_(out puCount);
                if ((errorCode >= 0) && (puCount > 0))
                {
                    uint puBuffLength = 0;
                    errorCode = wbemPath.GetText_(flags, ref puBuffLength, null);
                    if ((errorCode >= 0) && (puBuffLength > 0))
                    {
                        pszText   = new string('0', ((int)puBuffLength) - 1);
                        errorCode = wbemPath.GetText_(flags, ref puBuffLength, pszText);
                    }
                }
                if ((errorCode >= 0) || (errorCode == -2147217400))
                {
                    return(pszText);
                }
                if ((errorCode & 0xfffff000L) == 0x80041000L)
                {
                    ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode);
                    return(pszText);
                }
                Marshal.ThrowExceptionForHR(errorCode);
            }
            return(pszText);
        }
コード例 #3
0
        private static string GetWbemPath(IWbemPath wbemPath)
        {
            string pathStr = string.Empty;

            if (null != wbemPath)
            {
                // Requesting the path from a parser which has
                // been only given a relative path results in an incorrect
                // value being returned (e.g. \\.\win32_logicaldisk). To work
                // around this we check if there are any namespaces,
                // and if not ask for the relative path instead.
                int  flags  = (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_TOO;
                uint nCount = 0;

                int status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0)
                {
                    if (0 == nCount)
                    {
                        flags = (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY;
                    }

                    // Get the space we need to reserve
                    uint bufLen = 0;

                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && 0 < bufLen)
                    {
                        char[] pathChars = new char[(int)bufLen];
                        status  = wbemPath.GetText_(flags, ref bufLen, pathChars);
                        pathStr = new string(pathChars, 0, Array.IndexOf(pathChars, '\0'));
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER)
                    {
                        // Interpret as unspecified - return ""
                    }

                    else if ((status & 0xfffff000) == 0x80041000)
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    }
                    else
                    {
                        Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
                    }
                }
            }

            return(pathStr);
        }
コード例 #4
0
ファイル: ManagementPath.cs プロジェクト: dox0/DotNet471RS3
        private static string GetWbemPath(IWbemPath wbemPath)
        {
            String pathStr = String.Empty;

            if (null != wbemPath)
            {
                //



                int  flags  = (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_TOO;
                uint nCount = 0;

                int status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0)
                {
                    if (0 == nCount)
                    {
                        flags = (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY;
                    }

                    // Get the space we need to reserve
                    uint bufLen = 0;

                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && 0 < bufLen)
                    {
                        pathStr = new String('0', (int)bufLen - 1);
                        status  = wbemPath.GetText_(flags, ref bufLen, pathStr);
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER)
                    {
                        // Interpret as unspecified - return ""
                    }

                    else if ((status & 0xfffff000) == 0x80041000)
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    }
                    else
                    {
                        Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
                    }
                }
            }

            return(pathStr);
        }
コード例 #5
0
        internal static string GetNamespacePath(IWbemPath wbemPath, int flags)
        {
            string pathStr = string.Empty;

            if (null != wbemPath)
            {
                // Requesting the namespace path from a parser which has
                // been only given a relative path results in an incorrect
                // value being returned (e.g. \\.\). To work
                // around this, check if there are any namespaces,
                // and if not just return "".
                uint nCount = 0;
                int  status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0 && nCount > 0)
                {
                    // Get the space we need to reserve
                    uint bufLen = 0;
                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && bufLen > 0)
                    {
                        char[] pathChars = new char[(int)bufLen];
                        status  = wbemPath.GetText_(flags, ref bufLen, pathChars);
                        pathStr = new string(pathChars, 0, Array.IndexOf(pathChars, '\0'));
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER)
                    {
                        // Interpret as unspecified - return ""
                    }
                    else if ((status & 0xfffff000) == 0x80041000)
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    }
                    else
                    {
                        Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f());
                    }
                }
            }

            return(pathStr);
        }
コード例 #6
0
        internal string GetNamespacePath(IWbemPath wbemPath, int flags)
        {
            string pathStr = String.Empty;

            if (null != wbemPath)
            {
                // TODO - due to a bug in the current WMI path
                // parser, requesting the namespace path from a parser which has
                // been only given a relative path results in an incorrect
                // value being returned (e.g. \\.\). To work
                // around this for now we check if there are any namespaces,
                // and if not just return "".
                uint nCount = 0;
                int  status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0 && nCount > 0)
                {
                    // Get the space we need to reserve
                    uint bufLen = 0;
                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && bufLen > 0)
                    {
                        pathStr = new String('0', (int)bufLen - 1);
                        status  = wbemPath.GetText_(flags, ref bufLen, pathStr);
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER)
                    {
                        ;                               // Interpret as unspecified - return ""
                    }
                    else if ((status & 0xfffff000) == 0x80041000)
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    }
                    else
                    {
                        Marshal.ThrowExceptionForHR(status);
                    }
                }
            }

            return(pathStr);
        }
コード例 #7
0
        internal static string GetNamespacePath(IWbemPath wbemPath, int flags)
        {
            string pathStr = String.Empty;

            if (null != wbemPath)
            {
                //



                uint nCount = 0;
                int  status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0 && nCount > 0)
                {
                    // Get the space we need to reserve
                    uint bufLen = 0;
                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && bufLen > 0)
                    {
                        pathStr = new String('0', (int)bufLen - 1);
                        status  = wbemPath.GetText_(flags, ref bufLen, pathStr);
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER)
                    {
                        // Interpret as unspecified - return ""
                    }
                    else if ((status & 0xfffff000) == 0x80041000)
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    }
                    else
                    {
                        Marshal.ThrowExceptionForHR(status);
                    }
                }
            }

            return(pathStr);
        }
コード例 #8
0
        private static string GetWbemPath(IWbemPath wbemPath)
        {
            string empty = string.Empty;

            if (wbemPath != null)
            {
                int  num             = 4;
                uint num1            = 0;
                int  namespaceCount_ = wbemPath.GetNamespaceCount_(out num1);
                if (namespaceCount_ >= 0)
                {
                    if (num1 == 0)
                    {
                        num = 2;
                    }
                    int num2 = 0;
                    namespaceCount_ = wbemPath.GetText_(num, out num2, null);
                    if (namespaceCount_ >= 0 && 0 < num2)
                    {
                        empty           = new string('0', num2 - 1);
                        namespaceCount_ = wbemPath.GetText_(num, out num2, empty);
                    }
                }
                if (namespaceCount_ < 0 && namespaceCount_ != -2147217400)
                {
                    if (((long)namespaceCount_ & (long)-4096) != (long)-2147217408)
                    {
                        Marshal.ThrowExceptionForHR(namespaceCount_);
                    }
                    else
                    {
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)namespaceCount_);
                    }
                }
            }
            return(empty);
        }
コード例 #9
0
 private static string GetWbemPath(IWbemPath wbemPath)
 {
     string pszText = string.Empty;
     if (wbemPath != null)
     {
         int lFlags = 4;
         uint puCount = 0;
         int errorCode = 0;
         errorCode = wbemPath.GetNamespaceCount_(out puCount);
         if (errorCode >= 0)
         {
             if (puCount == 0)
             {
                 lFlags = 2;
             }
             uint puBuffLength = 0;
             errorCode = wbemPath.GetText_(lFlags, ref puBuffLength, null);
             if ((errorCode >= 0) && (0 < puBuffLength))
             {
                 pszText = new string('0', ((int) puBuffLength) - 1);
                 errorCode = wbemPath.GetText_(lFlags, ref puBuffLength, pszText);
             }
         }
         if ((errorCode >= 0) || (errorCode == -2147217400))
         {
             return pszText;
         }
         if ((errorCode & 0xfffff000L) == 0x80041000L)
         {
             ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode);
             return pszText;
         }
         Marshal.ThrowExceptionForHR(errorCode);
     }
     return pszText;
 }
コード例 #10
0
        internal static string GetNamespacePath(IWbemPath wbemPath, int flags)
        {
            string pathStr = String.Empty;

            if (null != wbemPath)
            {
                // 





                uint nCount = 0;
                int status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0 && nCount > 0)
                {
                    // Get the space we need to reserve
                    uint bufLen = 0;
                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && bufLen > 0)
                    {
                        pathStr = new String ('0', (int) bufLen-1);
                        status = wbemPath.GetText_(flags, ref bufLen, pathStr);
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER) 
                    {
                        // Interpret as unspecified - return ""
                    }
                    else if ((status & 0xfffff000) == 0x80041000)
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    else
                        Marshal.ThrowExceptionForHR(status);
                }
            }

            return pathStr;
        }
コード例 #11
0
        private static string GetWbemPath(IWbemPath wbemPath)
        {
            String pathStr = String.Empty;

            if (null != wbemPath)
            {
                // 





                int flags = (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_SERVER_TOO;
                uint nCount = 0;

                int status = (int)ManagementStatus.NoError;

                status = wbemPath.GetNamespaceCount_(out nCount);

                if (status >= 0)
                {
                    if (0 == nCount)
                        flags = (int)tag_WBEM_GET_TEXT_FLAGS.WBEMPATH_GET_RELATIVE_ONLY;

                    // Get the space we need to reserve
                    uint bufLen = 0;
                
                    status = wbemPath.GetText_(flags, ref bufLen, null);

                    if (status >= 0 && 0 < bufLen)
                    {
                        pathStr = new String ('0', (int) bufLen-1);
                        status = wbemPath.GetText_(flags, ref bufLen, pathStr);
                    }
                }

                if (status < 0)
                {
                    if (status == (int)tag_WBEMSTATUS.WBEM_E_INVALID_PARAMETER) 
                    {
                        // Interpret as unspecified - return ""
                    }
                    
                    else if ((status & 0xfffff000) == 0x80041000)
                        ManagementException.ThrowWithExtendedInfo((ManagementStatus)status);
                    else
                        Marshal.ThrowExceptionForHR(status);
                }
            }

            return pathStr;
        }
コード例 #12
0
ファイル: ManagementPath.cs プロジェクト: nickchal/pash
		private static string GetWbemPath(IWbemPath wbemPath)
		{
			string empty = string.Empty;
			if (wbemPath != null)
			{
				int num = 4;
				uint num1 = 0;
				int namespaceCount_ = wbemPath.GetNamespaceCount_(out num1);
				if (namespaceCount_ >= 0)
				{
					if (num1 == 0)
					{
						num = 2;
					}
					int num2 = 0;
					namespaceCount_ = wbemPath.GetText_(num, out num2, null);
					if (namespaceCount_ >= 0 && 0 < num2)
					{
						empty = new string('0', num2 - 1);
						namespaceCount_ = wbemPath.GetText_(num, out num2, empty);
					}
				}
				if (namespaceCount_ < 0 && namespaceCount_ != -2147217400)
				{
					if (((long)namespaceCount_ & (long)-4096) != (long)-2147217408)
					{
						Marshal.ThrowExceptionForHR(namespaceCount_);
					}
					else
					{
						ManagementException.ThrowWithExtendedInfo((ManagementStatus)namespaceCount_);
					}
				}
			}
			return empty;
		}
コード例 #13
0
ファイル: ManagementPath.cs プロジェクト: nickchal/pash
		internal static string GetNamespacePath(IWbemPath wbemPath, int flags)
		{
			string empty = string.Empty;
			if (wbemPath != null)
			{
				uint num = 0;
				int namespaceCount_ = wbemPath.GetNamespaceCount_(out num);
				if (namespaceCount_ >= 0 && num > 0)
				{
					int num1 = 0;
					namespaceCount_ = wbemPath.GetText_(flags, out num1, null);
					if (namespaceCount_ >= 0 && num1 > 0)
					{
						empty = new string('0', num1 - 1);
						namespaceCount_ = wbemPath.GetText_(flags, out num1, empty);
					}
				}
				if (namespaceCount_ < 0 && namespaceCount_ != -2147217400)
				{
					if (((long)namespaceCount_ & (long)-4096) != (long)-2147217408)
					{
						Marshal.ThrowExceptionForHR(namespaceCount_);
					}
					else
					{
						ManagementException.ThrowWithExtendedInfo((ManagementStatus)namespaceCount_);
					}
				}
			}
			return empty;
		}