⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phone.cs

📁 清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace Chapter9
{
    public static class Phone
    {
        public static void MakeCall(string number, bool prompt)
        {
            PHONEMAKECALLINFO pmci = new PHONEMAKECALLINFO();
            pmci.cbSize = Marshal.SizeOf(pmci);
            pmci.dwFlags = prompt ? PMCF.PROMPTBEFORECALLING : PMCF.DEFAULT;
            pmci.pszDestAddress = number;

            int result = PhoneMakeCall(ref pmci);

            if (result != 0)
            {
                //Ignore if user cancels the operation
                if (result != 0x000004C7)
                {
                    throw new System.ComponentModel.Win32Exception(result, "Error calling PhoneMakeCall");
                }
            }
        }

        //Phone API
        [DllImport("phone", SetLastError = true)]
        internal static extern int PhoneMakeCall(ref PHONEMAKECALLINFO ppmci);

        [StructLayout(LayoutKind.Sequential)]
        internal struct PHONEMAKECALLINFO
        {
            public int cbSize;
            public PMCF dwFlags;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pszDestAddress;
            [MarshalAs(UnmanagedType.LPWStr)]
            string pszAppName;
            [MarshalAs(UnmanagedType.LPWStr)]
            string pszCalledParty;
            [MarshalAs(UnmanagedType.LPWStr)]
            string pszComment;
        }

        internal enum PMCF
        {
            DEFAULT = 0x00000001,
            PROMPTBEFORECALLING = 0x00000002,
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -