如何检测PC上是否安装了Microsoft ActiveSync

时间:2009-06-23 13:41:56

标签: c# windows-mobile activesync

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

3 个答案:

答案 0 :(得分:7)

/// <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;
}

答案 1 :(得分:4)

您可以阅读注册表以检测是否已安装ActiveSync

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services 

答案 2 :(得分:0)

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