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

📄 netmapi.cs

📁 在PDA上打开收件箱,要将ReadSMS.dll拷到此程序部署到PDA的目录下
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace OpenInbox
{
    public class NetMAPI : IDisposable
    {
        protected IntPtr pMAPI;
        public NetMAPI()
        {
            pMAPI = IntPtr.Zero;
        }
        ~NetMAPI()
        {
            Dispose(false);
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        protected virtual void Dispose(bool disposing)
        {
            Logout();
        }
        public IntPtr MAPI
        {
            get { return pMAPI; }
        }
        public bool Login()
        {
            if (pMAPI == IntPtr.Zero) pMAPI = MAPILogin();
            return (pMAPI != IntPtr.Zero);
        }
        public void Logout()
        {
            if (pMAPI != IntPtr.Zero)
            {
                MAPILogout(pMAPI);
                pMAPI = IntPtr.Zero;
            }
        }
        public bool OpenMessageStore()
        {
            return MAPIOpenMessageStore(pMAPI);
        }
        public bool GetNextMessage(out SmsMessage message, bool bUnreadOnly)
        {
            IntPtr pMessage;
            message = null;
            if (MAPIGetNextMessage(pMAPI, out pMessage, bUnreadOnly))
            {
                message = new SmsMessage(pMessage);
            }
            return (message != null);
        }
        public bool GetContents()
        {
            return GetContents(IntPtr.Zero);
        }
        public bool OpenInbox()
        {
            return MAPIOpenInbox(pMAPI);
        }
        /// <summary>
        /// Opens the Outbox folder
        /// </summary>
        /// <returns>true on success</returns>
        public bool OpenOutbox()
        {
            return MAPIOpenOutbox(pMAPI);
        }

        /// <summary>
        /// Opens the Sent Items folder
        /// </summary>
        /// <returns>true on success</returns>
        public bool OpenSentItems()
        {
            return MAPIOpenSentItems(pMAPI);
        }

        /// <summary>
        /// Opens the Deleted Items folder
        /// </summary>
        /// <returns>true on success</returns>
        public bool OpenDeletedItems()
        {
            return MAPIOpenDeletedItems(pMAPI);
        }
        /// <summary>
        /// Opens the Drafts folder
        /// </summary>
        /// <returns>true on success</returns>
        public bool OpenDrafts()
        {
            return MAPIOpenDrafts(pMAPI);
        }
        /// <summary>
        /// Opens the contents of a specific folder
        /// </summary>
        /// <param name="pFolder"></param>
        /// <returns>true on success</returns>
        public bool GetContents(IntPtr pFolder)
        {
            return MAPIGetContents(pMAPI, pFolder);
        }
        public int GetRowCounts()
        {
            return MAPIGetRowCount(pMAPI);
        }
        [DllImport("ReadSMS.dll")]
        public static extern bool MAPIInit();

        [DllImport("ReadSMS.dll", EntryPoint = "MAPITerm")]
        public static extern void Term();

        // Profiles, Message Store

        [DllImport("ReadSMS.dll")]
        protected static extern IntPtr MAPILogin();

        [DllImport("ReadSMS.dll")]
        protected static extern void MAPILogout(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIOpenMessageStore(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIGetContents(IntPtr pMAPI, IntPtr pFolder);

        [DllImport("ReadSMS.dll")]
        protected static extern int MAPIGetRowCount(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIOpenInbox(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIOpenOutbox(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIOpenSentItems(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIOpenDeletedItems(IntPtr pMAPI);

        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIOpenDrafts(IntPtr pMAPI);
        [DllImport("ReadSMS.dll")]
        protected static extern bool MAPIGetNextMessage(IntPtr pMAPI, out IntPtr pMessage, bool bUnreadOnly);
    }
}

⌨️ 快捷键说明

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