public void SetDefaultEndPoint(string deviceId, EDataFlow flow, IEnumerable <ERole> roles, uint processId) { Trace.WriteLine($"ExtendedPolicyClient SetDefaultEndPoint {deviceId} [{flow}] {processId}"); try { if (string.IsNullOrEmpty(deviceId)) { return; } using var deviceIdStr = HSTRING.FromString(GenerateDeviceId(deviceId, flow)); foreach (var eRole in roles) { PolicyConfig.SetPersistedDefaultAudioEndpoint(processId, flow, eRole, deviceIdStr); } } catch (COMException e) when((e.ErrorCode & ErrorConst.COM_ERROR_MASK) == ErrorConst.COM_ERROR_NOT_FOUND) { throw new DeviceNotFoundException($"Can't set default as {deviceId}", e, deviceId); } catch (Exception ex) { Trace.WriteLine($"{ex}"); } }
static IXmlNodeList GetNodes(IXmlDocument xmldoc, string tagName) { IXmlNodeList nodes; using (var hStrign_tagName = HSTRING.FromString(tagName)) ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName(hStrign_tagName, out nodes)); return(nodes); }
static IXmlElement CreateElement(IXmlDocument xmldoc, string elementName) { IXmlElement element; using (var hStrign_elementName = HSTRING.FromString(elementName)) ComFunctions.CheckHRESULT(xmldoc.CreateElement(hStrign_elementName, out element)); return(element); }
static void SetNodeValueString(string str, IXmlDocument xmldoc, IXmlNode node) { IXmlText textNode; using (var hStrign_str = HSTRING.FromString(str)) ComFunctions.CheckHRESULT(xmldoc.CreateTextNode(hStrign_str, out textNode)); AppendNode(node, (IXmlNode)textNode); }
public static IAudioPolicyConfigFactory Create() { var iid = GuidGenerator.CreateIID(typeof(IAudioPolicyConfigFactory)); using var name = HSTRING.FromString("Windows.Media.Internal.AudioPolicyConfig"); ComBase.RoGetActivationFactory(name, ref iid, out object factory); return(factory.As <IAudioPolicyConfigFactory>()); }
public static unsafe void StringToHStringReference( char* pchPinnedSourceString, string sourceString, HSTRING_HEADER* pHeader, HSTRING* phString) { throw new PlatformNotSupportedException("StringToHStringReference"); }
/// <include file='WinRT.xml' path='doc/member[@name="WinRT.OriginateError"]/*' /> public static BOOL OriginateError(HRESULT error, HSTRING message) { if ((((HRESULT)(error)) >= 0)) { return(0); } return(RoOriginateError(error, message)); }
/// <include file='WinRT.xml' path='doc/member[@name="WinRT.TransformError"]/*' /> public static BOOL TransformError(HRESULT oldError, HRESULT newError, HSTRING message) { if ((oldError == newError) || ((((HRESULT)(oldError)) >= 0) && (((HRESULT)(newError)) >= 0))) { return(0); } return(RoTransformError(oldError, newError, message)); }
static void SetImageSrc(IXmlDocument xmldoc, string imagePath) { IXmlNode imageNode = GetNode(xmldoc, "image"); IXmlNode srcAttribute; using (var hString_name = HSTRING.FromString("src")) ComFunctions.CheckHRESULT(imageNode.Attributes.GetNamedItem(hString_name, out srcAttribute)); SetNodeValueString(imagePath, xmldoc, srcAttribute); }
string GetActivationString(IToastActivatedEventArgs args) { HSTRING activationString = new HSTRING(); if (args != null) { args.GetArguments(out activationString); } return(activationString.GetString()); }
public static string MarshalIntoString(this HSTRING hStr) { unsafe { uint length = 0; PCWSTR pBuffer = WindowsGetStringRawBuffer(hStr, &length); string str = new((char *)pBuffer, 0, (int)length); WindowsDeleteString(hStr); return(str); } }
public static unsafe string HStringToString(HSTRING pHString) { if (pHString.handle == IntPtr.Zero) { return String.Empty; } uint length = 0; char* pchBuffer = ExternalInterop.WindowsGetStringRawBuffer(pHString.handle.ToPointer(), &length); return new string(pchBuffer, 0, (int)length); }
public static unsafe void StringToHStringReference( char* pchPinnedSourceString, string sourceString, HSTRING_HEADER* pHeader, HSTRING* phString) { if (sourceString == null) throw new ArgumentNullException("sourceString", SR.Null_HString); int hr = ExternalInterop.WindowsCreateStringReference( pchPinnedSourceString, (uint)sourceString.Length, pHeader, (void**)phString); if (hr < 0) throw Marshal.GetExceptionForHR(hr); }
public string GetDesktopName(object desktop) { IComVirtualDesktop comDesktop = (IComVirtualDesktop)desktop; // get desktop name string?desktopName = null; try { desktopName = new HSTRING(comDesktop.GetName()).MarshalIntoString(); } catch { } // no name found, generate generic name if (string.IsNullOrEmpty(desktopName)) { // create name "Desktop n" (n = number starting with 1) desktopName = "Desktop " + (GetDesktopIndex(IntPtr.Zero, comDesktop) + 1).ToString(); } return(desktopName); }
public static HRESULT ActivateInstance <T>(HSTRING activatableClassId, T **instance) where T : unmanaged { *instance = null; IInspectable *pInspectable; HRESULT hr = RoActivateInstance(activatableClassId, &pInspectable); if (SUCCEEDED(hr)) { if (__uuidof <T>() == IID_IInspectable) { *instance = (T *)pInspectable; } else { hr = pInspectable->QueryInterface(__uuidof <T>(), (void **)instance); _ = pInspectable->Release(); } } return(hr); }
public HRESULT put_NextCorrelationVectorForThread(HSTRING cv) { return(((delegate * unmanaged <ICorrelationVectorInformation *, HSTRING, int>)(lpVtbl[8]))((ICorrelationVectorInformation *)Unsafe.AsPointer(ref this), cv)); }
static void SetAttribute(IXmlElement node, string attributeName, string attributeValue) { using (var hString_attributeName = HSTRING.FromString(attributeName)) using (var hString_attributeValue = HSTRING.FromString(attributeValue)) ComFunctions.CheckHRESULT(node.SetAttribute(hString_attributeName, hString_attributeValue)); }
internal static extern int RoOriginateLanguageException(int hr, HSTRING message, IntPtr pLanguageException);
public static extern uint WindowsGetStringLen(HSTRING @string);
public HRESULT RequestAccessForWindowAsync(HWND appWindow, HSTRING sourceIdentity, HSTRING targetIdentity, [NativeTypeName("const IID &")] Guid *riid, void **asyncOperation) { return(((delegate * unmanaged <IProtectionPolicyManagerInterop *, HWND, HSTRING, HSTRING, Guid *, void **, int>)(lpVtbl[6]))((IProtectionPolicyManagerInterop *)Unsafe.AsPointer(ref this), appWindow, sourceIdentity, targetIdentity, riid, asyncOperation)); }
static int GetIndexedProperty__STUB( System.IntPtr pComThis, HSTRING unsafe_name, TypeName unsafe_type, IntPtr __IntPtr__unsafe_customProperty) { //__com_Windows_UI_Xaml_Data__ICustomProperty** unsafe_customProperty = (__com_Windows_UI_Xaml_Data__ICustomProperty**)__IntPtr__unsafe_customProperty; void** unsafe_customProperty = (void**)__IntPtr__unsafe_customProperty; try { object target = ComCallableObject.FromThisPointer(pComThis).TargetObject; string propertyName = McgMarshal.HStringToString(unsafe_name); Type indexerType = McgMarshal.TypeNameToType(unsafe_type.Name, (int)unsafe_type.Kind); ICustomProperty property = ManagedGetIndexedProperty(target, propertyName, indexerType); *unsafe_customProperty = (void*)McgComHelpers.ManagedObjectToComInterface( property, typeof(ICustomProperty).TypeHandle); } catch (Exception ex) { return McgMarshal.GetHRForExceptionWinRT(ex); } return Interop.COM.S_OK; }
public static extern HRESULT WindowsSubstringWithSpecifiedLength(HSTRING @string, [NativeTypeName("UINT32")] uint startIndex, [NativeTypeName("UINT32")] uint length, HSTRING *newString);
internal static unsafe int StringToHStringNoNullCheck(string sourceString, HSTRING* hstring) { throw new PlatformNotSupportedException("StringToHStringNoNullCheck"); }
public static extern HRESULT WindowsDeleteString(HSTRING @string);
public static extern HRESULT WindowsSubstring(HSTRING @string, [NativeTypeName("UINT32")] uint startIndex, HSTRING *newString);
public static extern HRESULT WindowsStringHasEmbeddedNull(HSTRING @string, BOOL *hasEmbedNull);
public static extern BOOL WindowsIsStringEmpty(HSTRING @string);
public static extern ushort *WindowsGetStringRawBuffer(HSTRING @string, [NativeTypeName("UINT32 *")] uint *length);
public HRESULT SetActivitySourceHost(HSTRING activitySourceHost) { return ((delegate* unmanaged<IUserActivitySourceHostInterop*, HSTRING, int>)(lpVtbl[6]))((IUserActivitySourceHostInterop*)Unsafe.AsPointer(ref this), activitySourceHost); }
public static extern HRESULT WindowsConcatString(HSTRING string1, HSTRING string2, HSTRING *newString);
internal static unsafe string HStringToString(IntPtr hString) { HSTRING hstring = new HSTRING(hString); return HStringToString(hstring); }
public static extern HRESULT WindowsReplaceString(HSTRING @string, HSTRING stringReplaced, HSTRING stringReplaceWith, HSTRING *newString);
public static string HStringToString(HSTRING hString) { throw new PlatformNotSupportedException("HStringToString"); }
public static extern HRESULT WindowsTrimStringEnd(HSTRING @string, HSTRING trimString, HSTRING *newString);
static int GetCustomProperty__STUB( System.IntPtr pComThis, HSTRING unsafe_name, IntPtr __IntPtr__unsafe_customProperty) { void** unsafe_customProperty = (void**)__IntPtr__unsafe_customProperty; object target = ComCallableObject.FromThisPointer(pComThis).TargetObject; string propertyName = McgMarshal.HStringToString(unsafe_name); try { ICustomProperty property = ManagedGetCustomProperty(target, propertyName); *unsafe_customProperty = (void*)McgComHelpers.ManagedObjectToComInterface( property, typeof(ICustomProperty).TypeHandle); } catch (Exception ex) { return McgMarshal.GetHRForExceptionWinRT(ex); } return Interop.COM.S_OK; }
public static extern int RoOriginateError(int hr, HSTRING hstring);
static internal extern int RoOriginateLanguageException(int hr, HSTRING message, IntPtr pLanguageException);
public static extern HRESULT WindowsCompareStringOrdinal(HSTRING string1, HSTRING string2, [NativeTypeName("INT32 *")] int *result);
public static extern HRESULT WindowsDuplicateString(HSTRING @string, HSTRING *newString);