private static void SetWbemPath(IWbemPath wbemPath, string path) { if (null != wbemPath) { uint flags = (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; //For now we have to special-case the "root" namespace - // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name if (string.Equals(path, "root", StringComparison.OrdinalIgnoreCase)) { flags |= (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; } int status = wbemPath.SetText_(flags, path); if (status < 0) { if ((status & 0xfffff000) == 0x80041000) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); } else { Marshal.ThrowExceptionForHR(status, WmiNetUtilsHelper.GetErrorInfo_f()); } } } }
private void CreateNewPath(string path) { wmiPath = (IWbemPath) new WbemDefPath(); uint flags = (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; //For now we have to special-case the "root" namespace - // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name //TODO : fix this so that special-casing is not needed if (path.ToLower().Equals("root")) { flags = flags | (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; } int status = (int)ManagementStatus.NoError; try { status = wmiPath.SetText_(flags, path); } catch (Exception e) { // BUGBUG : old throw new ArgumentOutOfRangeException ("path"); new: ManagementException.ThrowWithExtendedInfo(e); } if ((status & 0xfffff000) == 0x80041000) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); } else if ((status & 0x80000000) != 0) { Marshal.ThrowExceptionForHR(status); } }
private void SetWbemPath(IWbemPath wbemPath, string path) { if (null != wbemPath) { uint flags = (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; //For now we have to special-case the "root" namespace - // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name //TODO : fix this so that special-casing is not needed if (path.ToLower(CultureInfo.InvariantCulture).Equals("root")) { flags = flags | (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; } int status = wbemPath.SetText_(flags, path); if (status < 0) { if ((status & 0xfffff000) == 0x80041000) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); } else { Marshal.ThrowExceptionForHR(status); } } } }
//Used to update the relative path when the user changes any key properties internal void UpdateRelativePath(string relPath) { if (relPath == null) { return; } //Get the server & namespace part from the existing path, and concatenate the given relPath. //NOTE : we need to do this because IWbemPath doesn't have a function to set the relative path alone... string newPath = String.Empty; string nsPath = this.NamespacePath; if (nsPath != String.Empty) { newPath = String.Concat(this.NamespacePath, ":", relPath); } else { newPath = relPath; } if (wmiPath == null) { wmiPath = (IWbemPath) new WbemDefPath(); } //Set the flags for the SetText operation uint flags = (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; //Special-case the "root" namespace - // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name //TODO : fix this so that special-casing is not needed if (newPath.ToLower().Equals("root")) { flags = flags | (uint)tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; } int status = (int)ManagementStatus.NoError; try { status = wmiPath.SetText_(flags, newPath); } catch (Exception e) { // BUGBUG : old throw new ArgumentOutOfRangeException ("path"); new: ManagementException.ThrowWithExtendedInfo(e); } if ((status & 0xfffff000) == 0x80041000) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); } else if ((status & 0x80000000) != 0) { Marshal.ThrowExceptionForHR(status); } }
private static void SetWbemPath(IWbemPath wbemPath, string path) { if (wbemPath != null) { uint uMode = 4; if (string.Compare(path, "root", StringComparison.OrdinalIgnoreCase) == 0) { uMode |= 8; } int errorCode = wbemPath.SetText_(uMode, path); if (errorCode < 0) { if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus)errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } } }
private static void SetWbemPath(IWbemPath wbemPath, string path) { if (wbemPath != null) { uint num = 4; if (string.Compare(path, "root", StringComparison.OrdinalIgnoreCase) == 0) { num = num | 8; } int num1 = wbemPath.SetText_(num, path); if (num1 < 0) { if (((long)num1 & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num1); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num1); return; } } } }
private static void SetWbemPath(IWbemPath wbemPath, string path) { if (wbemPath != null) { uint uMode = 4; if (string.Compare(path, "root", StringComparison.OrdinalIgnoreCase) == 0) { uMode |= 8; } int errorCode = wbemPath.SetText_(uMode, path); if (errorCode < 0) { if ((errorCode & 0xfffff000L) == 0x80041000L) { ManagementException.ThrowWithExtendedInfo((ManagementStatus) errorCode); } else { Marshal.ThrowExceptionForHR(errorCode); } } } }
private static void SetWbemPath(IWbemPath wbemPath, string path) { if (null != wbemPath) { uint flags = (uint) tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_CREATE_ACCEPT_ALL; //For now we have to special-case the "root" namespace - // this is because in the case of "root", the path parser cannot tell whether // this is a namespace name or a class name // if (String.Compare(path, "root", StringComparison.OrdinalIgnoreCase) == 0) flags = flags | (uint) tag_WBEM_PATH_CREATE_FLAG.WBEMPATH_TREAT_SINGLE_IDENT_AS_NS; int status = wbemPath.SetText_(flags, path); if (status < 0) { if ((status & 0xfffff000) == 0x80041000) ManagementException.ThrowWithExtendedInfo((ManagementStatus)status); else Marshal.ThrowExceptionForHR(status); } } }
private static void SetWbemPath(IWbemPath wbemPath, string path) { if (wbemPath != null) { uint num = 4; if (string.Compare(path, "root", StringComparison.OrdinalIgnoreCase) == 0) { num = num | 8; } int num1 = wbemPath.SetText_(num, path); if (num1 < 0) { if (((long)num1 & (long)-4096) != (long)-2147217408) { Marshal.ThrowExceptionForHR(num1); } else { ManagementException.ThrowWithExtendedInfo((ManagementStatus)num1); return; } } } }