detect existense of wp7 sdk and particular components

117 Views Asked by At

Is there a way to programmatically detect the for the existence of the Windows Phone 7 SDK (versions 7.0, 7.1 and/or 7.11) and particular components such as the emulator, emulator version, emulator image version, assemblies, etc.

I'm looking to do this from a simple .NET 4 console app. How can I tell what WP7 SDK version a machine is using? has a little bit of information, but doesn't seem complete enough.

Thanks

2

There are 2 best solutions below

0
On

This is the class i use for device information

public class DeviceInformation
{
    public static Device GetDeviceInfo()
    {
        Device deviceInfo = new Device();
        deviceInfo.Id = getDeviceId();
        deviceInfo.Name = getDeviceName();
        deviceInfo.Manufacturer = getDeviceManufacturer();
        deviceInfo.OSVersion = System.Environment.OSVersion.ToString();
        deviceInfo.Language = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

        return deviceInfo;
    }

    private static String getDeviceId()
    {
        Object uniqueId;
        StringBuilder deviceId = new StringBuilder();
        if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
        {
            for (int i = 0; i < ((byte[])uniqueId).Length; i++)
            {
                deviceId.Append(((byte[])uniqueId)[i]);
            }
        }

        return deviceId.ToString();
    }

    private static String getDeviceName()
    {
        Object deviceName;
        DeviceExtendedProperties.TryGetValue("DeviceName", out deviceName);
        return deviceName.ToString();
    }

    private static String getDeviceManufacturer()
    {
        Object deviceManufacturer;
        DeviceExtendedProperties.TryGetValue("DeviceManufacturer", out deviceManufacturer);
        return deviceManufacturer.ToString();
    }
}

Greets

0
On

I believe, you want to get information about installed developer tools on developer machine. For that reason, one way could be to check the installed folders and for that following code can be used:

           public static List<double> GetSdkVersion()
           {
               var versions = new List<double>();
               var data = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86);
               var sdkPath = Path.Combine(data, @"Microsoft SDKs\Windows Phone\v7.0");
               var version = Directory.Exists(sdkPath);
               versions.Add(7.0);
               sdkPath = Path.Combine(data, @"Microsoft SDKs\Windows Phone\v7.1");
               return versions;
           }

            public static List<double> GetEmulatorVersios()
            {
                var versions = new List<double>();
                var data = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86);
                var sdkPath = Path.Combine(data, @"Microsoft XDE\1.0");
                var version = Directory.Exists(sdkPath);
                versions.Add(1.0);
                return versions;
            }

Indeed, there can be better to write this code, but this is what I can come with. Hope, it helps.