Microsoft ActiveSyncがPCにインストールされているかどうかを検出する方法

StackOverflow https://stackoverflow.com/questions/1032649

  •  06-07-2019
  •  | 
  •  

質問

PCにMicrosoft ActiveSyncがインストールされているかどうかを検出する最良/最も信頼できる方法は何ですか?私のPCプログラムはRAPIを使用してデバイスからファイルを取得します。インストールされていない場合、RAPI.dllが見つからないというエラーが発生します。

役に立ちましたか?

解決

レジストリを読み取って、ActiveSyncがインストールされているかどうかを検出できます

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services 

他のヒント

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

また、
C:\ Windows \ System32 \ rapi.dll が存在する
rapi.dllファイルをアプリケーションに含めようとしましたか?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top