【问题标题】:How to detect if Microsoft ActiveSync is installed on a PC如何检测 PC 上是否安装了 Microsoft ActiveSync
【发布时间】:2010-11-05 04:21:58
【问题描述】:

检测 PC 是否安装了 Microsoft ActiveSync 的最佳/最可靠方法是什么?我的 PC 程序使用 RAPI 从设备中获取文件,如果未安装,则会出现无法找到 RAPI.dll 的错误。

【问题讨论】:

    标签: c# windows-mobile activesync


    【解决方案1】:

    您可以读取注册表以检测是否安装了 ActiveSync

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services 
    

    【讨论】:

    • 警告:卸载 ActiveSync 后,此注册表项仍然存在。因此,在安装了 CE 但现在已被删除的机器上,您会得到误报。检查该键中是否存在值名称(例如:值“InstalledDir”/“BuildNumber”/“MajorVersion”/...应该存在于该注册表项中)
    • @FelixAlcala:是的,这就是我的答案检查的内容
    【解决方案2】:
    /// <summary>
    /// Checks to see if ActiveSync/Windows Mobile Device Center
    /// is installed on the PC.
    /// </summary>
    /// <param name="syncVersion">The version of the synchronization tool installed.</param>
    /// <returns>True: Either ActiveSync or Windows Mobile Device Center is 
    /// installed. False: version is null
    /// </returns>
    private static bool isActiveSyncInstalled(out Version syncVersion)
    {
                using (RegistryKey reg = 
                    Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows CE Services"))
                {
                    if (reg == null)
                    {
                        syncVersion = null;
                        return false;
                    }
    
                    int majorVersion = (int)reg.GetValue("MajorVersion", 0);
                    int minorVersion = (int)reg.GetValue("MinorVersion", 0);
                    int buildNumber = (int)reg.GetValue("BuildNumber", 0);
    
                    syncVersion = new Version(majorVersion, minorVersion, buildNumber);
                }
                return true;
    }
    

    【讨论】:

      【解决方案3】:

      您也可以检查
      C:\Windows\System32\rapi.dll是否存在
      您是否尝试在您的应用程序中包含 rapi.dll 文件?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-09-22
        • 1970-01-01
        • 1970-01-01
        • 2010-11-11
        • 2016-12-18
        • 2015-04-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多