Getting information about the OS, platform and device in Windows 8

How to get the following information about Windows 8?

Platform, OS version, device name, device identifier and carrier (not sure if the operator applies to Windows 8)

With Windows Phone 8, I retrieve them using:

Platform: Environment.OSVersion.Platform OS Version: Environment.OSVersion.Version Device name: Microsoft.Phone.Info.DeviceStatus.DeviceName Device ID: Windows.Phone.System.Analytics.HostInformation.PublisherHostId Carrier: Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.CellularMobileOperator 

I am looking for the equivalent of Windows 8 of the above Windows Phone 8 information using C #.

+4
source share
2 answers

Below you can get information here.

  • Windows version

  • Processor architecture

  • Device category

  • Device manufacturer

  • Device model

For a unique identifier, see UDID for Windows 8

Below you can get information here.

  • Application version

  • OS version

  • Car name

+3
source

I only got ItemNameKey, ModelNameKey, ManufacturerKey, or without hexadecimal numbers. Others do not, I do not know why. This is working code, but in C ++, and since nothing happens in C ++ / CX, I publish it here (it takes some time to figure out what namespaces are used in C #, and it took about an hour to figure out how to write something output and working Collections :: Iterable and collections :: Iterator in C ++)

 using namespace Windows::System; //using namespace Windows::System::L.Linq; using namespace Windows::System::Threading; using namespace Windows::Devices::Enumeration::Pnp; using namespace Collections; //public class SystemInfoEstimate //{ Platform::Array< Platform::String ^> ^StrArray;// = ref new Platform::Array< Platform::String ^>(1); ref class MyIterator sealed: IIterator<Platform::String ^> { int Index; public: MyIterator() { Index = 0; } property virtual Platform::String ^ Current { Platform::String ^ get() { return StrArray->get( Index ); } } property virtual bool HasCurrent { bool get() { return true; } } virtual bool MoveNext() { Index++; if (Index >=StrArray->Length) return false; return true; } virtual unsigned int GetMany( Platform::WriteOnlyArray<Platform::String ^> ^Arr) { for(int i=0; i<StrArray->Length; i++) { Arr->set( i, StrArray[i] ); } return StrArray->Length; } }; ref class MyIterable sealed: IIterable<Platform::String ^> { public: virtual IIterator<Platform::String ^> ^First() { return ref new MyIterator();//StrArray[0]; } }; Platform::String ^ItemNameKey = "System.ItemNameDisplay"; Platform::String ^ ModelNameKey = "System.Devices.ModelName"; Platform::String ^ ManufacturerKey = "System.Devices.Manufacturer"; Platform::String ^ DeviceClassKey = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10"; Platform::String ^ PrimaryCategoryKey = "{78C34FC8-104A-4ACA-9EA4-524D52996E57},97"; Platform::String ^ DeviceDriverVersionKey = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3"; Platform::String ^ RootContainer = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}"; Platform::String ^ RootQuery = "System.Devices.ContainerId:=\"" + RootContainer + "\""; Platform::String ^ HalDeviceClass = "4d36e966-e325-11ce-bfc1-08002be10318"; void GetSystemInfo() { //return; StrArray = ref new Platform::Array< Platform::String ^>(2); MyIterable^ MI = ref new MyIterable(); StrArray->set( 0, ModelNameKey );//ManufacturerKey ); StrArray->set( 1, ManufacturerKey ); auto v = create_task( PnpObject::CreateFromIdAsync(PnpObjectType::DeviceContainer, RootContainer, MI )//StrArray); ); v.wait(); PnpObject ^Ret = v.get(); UINT Size = Ret->Properties->Size; if (Size > 0) { for(int i=0; i<StrArray->Length; i++) { IIterator< IKeyValuePair< Platform::String ^, Platform::Object ^>^ > ^ It = Ret->Properties->First(); bool Moving = true; while(Moving) { Platform::String ^PropStr = It->Current->Value->ToString(); //You could put OutputDebugString here ^ Moving = It->MoveNext(); } } } } 
+1
source

Source: https://habr.com/ru/post/1500366/


All Articles