3

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

4

3 回答 3

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;
}
于 2009-11-30T18:01:35.380 回答
4

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

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services 
于 2009-06-23T14:11:53.943 回答
0

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

于 2015-05-08T12:19:20.517 回答