Domanda

Qual è il modo migliore / più affidabile per rilevare se su un PC è installato Microsoft ActiveSync? Il mio programma per PC utilizza RAPI per rimuovere i file dal dispositivo e, se non è installato, si verifica un errore che non è possibile trovare RAPI.dll.

È stato utile?

Soluzione

Puoi leggere il registro per rilevare se ActiveSync è installato

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services 

Altri suggerimenti

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

Puoi anche verificare se
Esiste C: \ Windows \ System32 \ rapi.dll
Hai provato a includere il file rapi.dll con la tua applicazione?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top