Outlook 在哪里存储安装的 PST 文件?

发布于 2024-07-21 00:24:20 字数 1459 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

滥情空心 2024-07-28 00:24:20

这是一个内部实现细节,可能会随着版本的不同而发生变化。

That's an internal implementation detail subject to change from version to version.

山川志 2024-07-28 00:24:20

此代码(来自当前项目)搜索并解码 Unicode 和 Unicode 的名称和路径。 非 Unicode PST 文件。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Win32;

namespace PSTRemoval_v2
{
    class PSTRReg
    {
        public RegistryKey regOPs, regPR, regCU, regCP, regCC;

        public Dictionary<string, string> OpenPSTs = new Dictionary<string, string>();

        public Dictionary<string, string> ClosedPSTs = new Dictionary<string, string>();

        public Dictionary<string, string> PurgedPSTs = new Dictionary<string, string>();

        public void ValidRegEntries(Outlook.Application olApp)
        {
            string prf = olApp.Session.CurrentProfileName;  // retrieve current Outlook profile name.  Needed in case user has multiple profiles

            regCU = Registry.CurrentUser;

            regOPs = regCU.CreateSubKey(String.Format(@"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\{0}",prf));

            regPR = regCU.CreateSubKey(String.Format(@"Software\WRT\OutlookAddins\PSTRemoval\{0}", prf));  // create a subkey in the registry for this profile

            regCC = regPR.CreateSubKey(@"ClosedPSTs");
            regCP = regPR.CreateSubKey(@"PurgedPSTs");
        }

        public void OpenPSTs_REG_Read()
        {
            PSTRNet regnet = new PSTRNet();
            regnet.EnumerateNetworkDrives();

            string[] sk = regOPs.GetSubKeyNames();
            foreach (string subkey in sk)
            {
                RegistryKey rk2 = regOPs.OpenSubKey(subkey);
                if (rk2.ValueCount > 0)
                {
                    string[] vn = rk2.GetValueNames();
                    Array.Sort(vn);

                    int bs = Array.BinarySearch(vn, "001f3001"); // search for the PST Name
                    int bs1 = Array.BinarySearch(vn, "001f3006"); // PST Name alternative
                    if ((bs > -1) || (bs1 > -1))
                    {
                        int bs2 = Array.BinarySearch(vn, "001f6700");  // search for the PST Path
                        if (bs2 > -1)
                        {
                            // decode the Name & Path to text strings
                            string PSTName;
                            try { PSTName = decode(vn[bs], rk2); }
                            catch { PSTName = decode(vn[bs1], rk2); }
                            string PSTPath = decode(vn[bs2], rk2);

                            if (regnet.PSTOnNet(PSTPath))  // add the PST to the list if it is on a network drive
                            {
                                try
                                {
                                    OpenPSTs.Add(PSTPath, PSTName);
                                }
                                catch { }
                                regOPs.DeleteSubKey(subkey);  // then delete the entry from the main part of the registry
                            }
                        }
                    }
                }
            }
        }

        public void PSTs_REG_Read(RegistryKey regkey, Dictionary<string, string> entries)
        {
            string[] RK = regkey.GetValueNames();
            if (RK.Length > 0)
                foreach (string ValueName in RK)
                    try { entries.Add(ValueName, regkey.GetValue(ValueName).ToString()); }
                    catch { }
        }

        public void PSTs_Reg_write(RegistryKey regKey, Dictionary<string, string> entries)
        {
            string[] RK_Delete = regKey.GetValueNames();
            if (RK_Delete.Length > 0)
                foreach (string ValueName in RK_Delete)
                    regKey.DeleteValue(ValueName);

            foreach (KeyValuePair<string, string> kvp in entries)
                regKey.SetValue(kvp.Key, kvp.Value);
        }

        private string decode(string value, RegistryKey rk)  // decode registry entries from Unicode to plain text
        {
            byte[] b = (byte[])rk.GetValue(value);


         return Encoding.Unicode.GetString(b);
            }
        }
    }
}

注册表项为 Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\

001f301 是 unicode PST 的名称

This code (from a current project) searches for and decodes the names and paths of both Unicode & Non-Unicode PST files.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Win32;

namespace PSTRemoval_v2
{
    class PSTRReg
    {
        public RegistryKey regOPs, regPR, regCU, regCP, regCC;

        public Dictionary<string, string> OpenPSTs = new Dictionary<string, string>();

        public Dictionary<string, string> ClosedPSTs = new Dictionary<string, string>();

        public Dictionary<string, string> PurgedPSTs = new Dictionary<string, string>();

        public void ValidRegEntries(Outlook.Application olApp)
        {
            string prf = olApp.Session.CurrentProfileName;  // retrieve current Outlook profile name.  Needed in case user has multiple profiles

            regCU = Registry.CurrentUser;

            regOPs = regCU.CreateSubKey(String.Format(@"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\{0}",prf));

            regPR = regCU.CreateSubKey(String.Format(@"Software\WRT\OutlookAddins\PSTRemoval\{0}", prf));  // create a subkey in the registry for this profile

            regCC = regPR.CreateSubKey(@"ClosedPSTs");
            regCP = regPR.CreateSubKey(@"PurgedPSTs");
        }

        public void OpenPSTs_REG_Read()
        {
            PSTRNet regnet = new PSTRNet();
            regnet.EnumerateNetworkDrives();

            string[] sk = regOPs.GetSubKeyNames();
            foreach (string subkey in sk)
            {
                RegistryKey rk2 = regOPs.OpenSubKey(subkey);
                if (rk2.ValueCount > 0)
                {
                    string[] vn = rk2.GetValueNames();
                    Array.Sort(vn);

                    int bs = Array.BinarySearch(vn, "001f3001"); // search for the PST Name
                    int bs1 = Array.BinarySearch(vn, "001f3006"); // PST Name alternative
                    if ((bs > -1) || (bs1 > -1))
                    {
                        int bs2 = Array.BinarySearch(vn, "001f6700");  // search for the PST Path
                        if (bs2 > -1)
                        {
                            // decode the Name & Path to text strings
                            string PSTName;
                            try { PSTName = decode(vn[bs], rk2); }
                            catch { PSTName = decode(vn[bs1], rk2); }
                            string PSTPath = decode(vn[bs2], rk2);

                            if (regnet.PSTOnNet(PSTPath))  // add the PST to the list if it is on a network drive
                            {
                                try
                                {
                                    OpenPSTs.Add(PSTPath, PSTName);
                                }
                                catch { }
                                regOPs.DeleteSubKey(subkey);  // then delete the entry from the main part of the registry
                            }
                        }
                    }
                }
            }
        }

        public void PSTs_REG_Read(RegistryKey regkey, Dictionary<string, string> entries)
        {
            string[] RK = regkey.GetValueNames();
            if (RK.Length > 0)
                foreach (string ValueName in RK)
                    try { entries.Add(ValueName, regkey.GetValue(ValueName).ToString()); }
                    catch { }
        }

        public void PSTs_Reg_write(RegistryKey regKey, Dictionary<string, string> entries)
        {
            string[] RK_Delete = regKey.GetValueNames();
            if (RK_Delete.Length > 0)
                foreach (string ValueName in RK_Delete)
                    regKey.DeleteValue(ValueName);

            foreach (KeyValuePair<string, string> kvp in entries)
                regKey.SetValue(kvp.Key, kvp.Value);
        }

        private string decode(string value, RegistryKey rk)  // decode registry entries from Unicode to plain text
        {
            byte[] b = (byte[])rk.GetValue(value);


         return Encoding.Unicode.GetString(b);
            }
        }
    }
}

The registry entry is Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\<ProfileName>

001f301 is the name of the unicode PST

违心° 2024-07-28 00:24:20

顺便说一句,它在注册表中。

It's in the registry, by the way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文