示例#1
0
        public static IAsyncOperation <UserConsentVerificationResult> RequestVerificationForWindowAsync(IntPtr hWnd, string Message)
        {
            Guid iid = typeof(IAsyncOperation <UserConsentVerificationResult>).GUID;
            IUserConsentVerifierInterop factory = InteropHelper.GetActivationFactory <IUserConsentVerifierInterop>(typeof(UserConsentVerifier));

            return(factory.RequestVerificationForWindowAsync(hWnd, Message, ref iid));
        }
        public static IAsyncOperation <UserConsentVerificationResult> RequestVerificationForWindowAsync(IntPtr hWnd, string Message)
        {
            IUserConsentVerifierInterop userConsentVerifierInterop = (IUserConsentVerifierInterop)WindowsRuntimeMarshal.GetActivationFactory(typeof(UserConsentVerifier));
            Guid guid = typeof(IAsyncOperation <UserConsentVerificationResult>).GUID;

            return(userConsentVerifierInterop.RequestVerificationForWindowAsync(hWnd, Message, ref guid));
        }
        public static IAsyncOperation <UserConsentVerificationResult> RequestVerificationForWindowAsync(IntPtr hWnd, string Message)
        {
            //Use WinRT's GuidGenerator to get the correct guid
            var guid = GuidGenerator.CreateIID(typeof(IAsyncOperation <UserConsentVerificationResult>));

            //leverage winrt .As<> operator to cast winrt type to its interop interface
            IUserConsentVerifierInterop userConsentVerifierInterop = UserConsentVerifier.As <IUserConsentVerifierInterop>();

            //Handle marshalling the string to WinRT's HString
            var marshalStr = MarshalString.CreateMarshaler(Message);

            //Call the Interop api that pops a dialog, passing in the hWnd parameter
            IntPtr outPtr;

            userConsentVerifierInterop.RequestVerificationForWindowAsync(hWnd, MarshalString.GetAbi(marshalStr), ref guid, out outPtr);

            //Marshal the return object as an IAsyncOperation<>
            return((IAsyncOperation <UserConsentVerificationResult>)IInspectable.FromAbi(outPtr));
        }