Pergunta

Qual é a melhor e mais confiável forma de detectar se um PC tem instalado o Microsoft ActiveSync?Meu PC usa o programa RAPI para obter os arquivos do dispositivo e se ele não estiver instalado há um erro que RAPI.dll não pode ser encontrado.

Foi útil?

Solução

Você pode ler o registro para detectar se o ActiveSync está instalado

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services 

Outras dicas

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

Você também pode verificar se
C:\Windows\System32 api.dll existe
Você já tentou incluir rapi.dll arquivo com o seu aplicativo ?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top