Activate and obtain Windows Phone and simulator information on your computer

Source: Internet
Author: User

Note that the source code must be referenced by the user: Microsoft. smartdevice. Connectivity. dll

 

For the Windows Phone 7 SDK after the correct installation, the platform and device queried in the datastoremanager type should be like this.

=== Platform ===

Windows Phone 7

=== Device ===

Windows Phone Device

Windows Phone emulator-512 MB

Windows Phone emulator-256 MB

 

The Code is as follows:

// + Using Microsoft. smartdevice. connectivity;

 

VaR Mgr = new datastoremanager (system. Globalization. cultureinfo. currentculture. lcid );

Console. writeline ("=== platform === ");

Foreach (VAR platform in Mgr. getplatforms ())

{

Console. writeline (platform. Name );

Console. writeline ("=== device === ");

Foreach (VAR device in platform. getdevices ())

Console. writeline (device. Name );

}

 

The device can be activated through the device. Activate method, but only if the device has been connected and the connection can be through the connect method. For example, if we want to activate a MB simulator, the Code is as follows:

// + Using Microsoft. smartdevice. connectivity;

VaR Mgr = new datastoremanager (system. Globalization. cultureinfo. currentculture. lcid );

Foreach (VAR platform in Mgr. getplatforms ())

{

Foreach (VAR device in platform. getdevices ())

{

Try

{

// Search for the 512 characters in the name

If (device. Name. Contains ("512 "))

{

// Connection

Device. Connect ();

// Activate

Device. Activate ();

}

}

Catch (exception E)

{

Console. writeline (E );

}

}

}

 

OK. After the program is run, the corresponding Windows Phone simulator will run:

 

In addition, the device. isenumator method can be used to determine whether the target device is a simulator.

 

You can use the device. getsysteminfo method to query any device information, including the simulator and the actual device. Getsysteminfo returns a systeminfo object containing multiple options.

 

Sit down with your phone and test. First connect your phone to your computer, and then start Zune. Call device. Connect and getsysteminfo.

 

Complete code:

// + Using Microsoft. smartdevice. connectivity;

// + Using system. componentmodel; used to quickly output all attributes

 

Static void main (string [] ARGs)

{

VaR Mgr = new datastoremanager (system. Globalization. cultureinfo. currentculture. lcid );

Foreach (VAR platform in Mgr. getplatforms ())

{

Foreach (VAR device in platform. getdevices ())

{

Try

{

// Windows Phone device is required, which indicates the actual device connected

If (device. Name. Contains ("device "))

{

// Connection

Device. Connect ();

// Activate

Device. Activate ();

// Output information

Printproperties (device. getsysteminfo ());

}

}

Catch (exception E)

{

Console. writeline (E );

}

}

}

}

 

// Quickly output all attributes

Static void printproperties (Object OBJ)

{

Foreach (propertydescriptor descriptor in typedescriptor. getproperties (OBJ ))

{

String name = descriptor. Name;

Object value = descriptor. getvalue (OBJ );

Console. writeline ("{0 }:{ 1}", name, value );

}

}

 

OK, and the result will be output:

Osmajor: 7

Osminor: 10

Osbuildno: 8107

Processorarchitecture: Arm

Instructionset: armv4ifp

Numberofprocessors: 1

......

 

A lot of information, such as operating system version: 7.10.8107, processor type: arm, instruction set: armv4ifp ......

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.