public WindowsStoreDeviceInfoService() { this.deviceId = new Lazy <string>(() => { HardwareToken myToken = HardwareIdentification.GetPackageSpecificToken(null); return(myToken.Id.ToString()); }); switch (GetScaleFactor()) { case 150: this.ScreenWidth = 720; this.ScreenHeight = 1280; break; case 160: this.ScreenWidth = 768; this.ScreenHeight = 1280; break; case 100: default: this.ScreenWidth = 480; this.ScreenHeight = 800; break; } }
#pragma warning restore 1998 /// <summary> /// Gets the device unique identifier. /// </summary> /// <returns>The discovered device identifier.</returns> public virtual string GetDeviceUniqueId() { string deviceId = null; try { // Per documentation here http://msdn.microsoft.com/en-us/library/windows/apps/jj553431.aspx we are selectively pulling out // specific items from the hardware ID. StringBuilder builder = new StringBuilder(); HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); using (DataReader dataReader = DataReader.FromBuffer(token.Id)) { int offset = 0; while (offset < token.Id.Length) { // The first two bytes contain the type of the component and the next two bytes contain the value. byte[] hardwareEntry = new byte[4]; dataReader.ReadBytes(hardwareEntry); if ((hardwareEntry[0] == 1 || // CPU ID of the processor hardwareEntry[0] == 2 || // Size of the memory hardwareEntry[0] == 3 || // Serial number of the disk device hardwareEntry[0] == 7 || // Mobile broadband ID hardwareEntry[0] == 9) && // BIOS hardwareEntry[1] == 0) { if (builder.Length > 0) { builder.Append(','); } builder.Append(hardwareEntry[2]); builder.Append('_'); builder.Append(hardwareEntry[3]); } offset += 4; } } // create a buffer containing the cleartext device ID IBuffer clearBuffer = CryptographicBuffer.ConvertStringToBinary(builder.ToString(), BinaryStringEncoding.Utf8); // get a provider for the SHA256 algorithm HashAlgorithmProvider hashAlgorithmProvider = HashAlgorithmProvider.OpenAlgorithm("SHA256"); // hash the input buffer IBuffer hashedBuffer = hashAlgorithmProvider.HashData(clearBuffer); deviceId = CryptographicBuffer.EncodeToBase64String(hashedBuffer); } catch (Exception) { // For IoT sceanrios we will alwasy set the device id to IoT // Becuase HardwareIdentification API will always throw deviceId = "IoT"; } return(deviceId); }
//--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- #endregion //--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- #endregion //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- /// <summary> /// Returns a hex string representing an unique device ID. /// The device ID is a SHA256 hash, hex string of the actual device ID XOR a device nonce to prevent tracking between apps. /// </summary> public static string GetUniqueDeviceId() { byte[] deviceId; SystemIdentificationInfo systemId = SystemIdentification.GetSystemIdForPublisher(); if (systemId.Source != SystemIdentificationSource.None) { deviceId = systemId.Id.ToArray(); } else { // Fall back to generating a unique ID based on the hardware of the system. // This ID will change once the hardware changes. // Based on: https://montemagno.com/unique-device-id-for-mobile-apps/ HardwareToken hwToken = HardwareIdentification.GetPackageSpecificToken(null); deviceId = hwToken.Id.ToArray(); } byte[] nonce = GetDeviceNonce(); // Ensure the device ID is long enough: deviceId = deviceId.Length >= 32 ? XorShorten(deviceId, nonce) : nonce; SHA256 sha = SHA256.Create(); deviceId = sha.ComputeHash(deviceId); return(ByteArrayToHexString(deviceId)); }
/// <summary> /// Compute a stable application specific client instance id string for use as "clientInstanceId" parameters in IXboxMusicClient /// </summary> /// <returns>A valid clientInstanceId string. This string is specific to the current machine, user and application.</returns> private static string ComputeClientInstanceId() { // Generate a somewhat stable application instance id HardwareToken ashwid = HardwareIdentification.GetPackageSpecificToken(null); byte[] id = ashwid.Id.ToArray(); string idstring = Package.Current.Id.Name + ":"; for (int i = 0; i < id.Length; i += 4) { short what = BitConverter.ToInt16(id, i); short value = BitConverter.ToInt16(id, i + 2); // Only include stable components in the id // http://msdn.microsoft.com/en-us/library/windows/apps/jj553431.aspx const int cpuId = 1; const int memorySize = 2; const int diskSerial = 3; const int bios = 9; if (what == cpuId || what == memorySize || what == diskSerial || what == bios) { idstring += value.ToString("X4"); } } return(idstring.PadRight(32, 'X')); }
/// <summary> /// 开始发送使用信息 /// </summary> /// <param name="mod"></param> private async void Begin_tongji_Run(string mod) { try { ClassHttp CH = new ClassHttp(); CH.HttpURL = URLSTR.tongji; IDictionary <string, string> CS = new Dictionary <string, string>(); //可选参数,但如果要获取的地址不是网页,而是一个文件或图片,服务器一般默认配置不接受Post进而导致无法获取到。 //直接使用图片地址的,不要设置这个参数,避免使用Post方式,直接传递null。 HardwareToken hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); EasClientDeviceInformation easClientDeviceInformation = new EasClientDeviceInformation(); CS["mod"] = mod; CS["hardwareToken_Id"] = Buffer2Base64(hardwareToken.Id); CS["hardwareToken_Signature"] = Buffer2Base64(hardwareToken.Signature); CS["hardwareToken_Certificate"] = Buffer2Base64(hardwareToken.Certificate); CS["easClientDeviceInformation_Version"] = "固件版本:" + easClientDeviceInformation.SystemFirmwareVersion + "★硬件版本:" + easClientDeviceInformation.SystemHardwareVersion; CS["easClientDeviceInformation_FriendlyName"] = easClientDeviceInformation.FriendlyName; CS["easClientDeviceInformation_OperatingSystem"] = easClientDeviceInformation.OperatingSystem; CS["easClientDeviceInformation_SystemManufacturer"] = easClientDeviceInformation.SystemManufacturer; CS["easClientDeviceInformation_SystemProductName"] = easClientDeviceInformation.SystemProductName; IDictionary <string, object> RE = await CH.LoadHttpText(CS); } catch (Exception exx) { } }
public static string GetDeviceId() { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer hardwareId = token.Id; HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5"); IBuffer hashed = hasher.HashData(hardwareId); return(CryptographicBuffer.EncodeToHexString(hashed)); }
/// <summary> ///获取设备唯一ID /// </summary> /// <returns></returns> public static string GetUniqueDeviceId() { HardwareToken ht = HardwareIdentification.GetPackageSpecificToken(null); var id = ht.Id; var dataReader = DataReader.FromBuffer(id); byte[] bytes = new byte[id.Length]; dataReader.ReadBytes(bytes); string s = BitConverter.ToString(bytes); return(s.Replace("-", "")); }
static string GetDeviceIdImpl() { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer hardwareId = token.Id; var dataReader = DataReader.FromBuffer(hardwareId); var bytes = new byte[hardwareId.Length]; dataReader.ReadBytes(bytes); return(BitConverter.ToString(bytes)); }
private static string GetUniqueDeviceId() { HardwareToken ht = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null); var id = ht.Id; var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(id); byte[] bytes = new byte[id.Length]; dataReader.ReadBytes(bytes); string s = BitConverter.ToString(bytes); return(s.Replace("-", "")); }
/// <summary> /// It is recommended you generate a way that is unique for the app/device. In this example we normalize the hardware /// ID for things that rarely change and add a few strings related to the app. /// See http://code.msdn.microsoft.com/windowsapps/How-to-use-ASHWID-to-3742c83e for examples on ASHWID use. /// </summary> /// <returns></returns> private static string GetDeviceUniqueId() { HardwareToken id = HardwareIdentification.GetPackageSpecificToken(null); string normalized = NormalizeHardwareId(id.Id.ToArray()); HashAlgorithmProvider alg = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames); IBuffer buff = CryptographicBuffer.ConvertStringToBinary(normalized + typeof(HmacSHA256KeyGenerator).FullName, BinaryStringEncoding.Utf8); IBuffer hashed = alg.HashData(buff); return(CryptographicBuffer.EncodeToHexString(hashed)); }
private static string GetDeviceIdInternal() { // HardwareIdentification does not work on HoloLens/Xbox One/Surface Hub or IoT before Windows 10.0.14393 if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Profile.HardwareIdentification")) { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); byte[] bytes = token.Id.ToArray(); return(BitConverter.ToString(bytes)); } else { // using random string as a fallback IBuffer deviceIdBuffer = CryptographicBuffer.GenerateRandom(32); return(CryptographicBuffer.EncodeToHexString(deviceIdBuffer)); } }
//--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- #endregion //--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- #endregion //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- /// <summary> /// Returns a hex string representing an unique device ID. /// </summary> public static string GetUniqueDeviceId() { SystemIdentificationInfo systemId = SystemIdentification.GetSystemIdForPublisher(); if (systemId.Source != SystemIdentificationSource.None) { return(ByteArrayToHexString(systemId.Id.ToArray())); } // Fall back to generating a unique ID based on the hardware of the system. // This ID will change once the hardware changes. // Based on: https://montemagno.com/unique-device-id-for-mobile-apps/ HardwareToken hwToken = HardwareIdentification.GetPackageSpecificToken(null); return(ByteArrayToHexString(hwToken.Id.ToArray())); }
public string GetDeviceId() { // get the unique device id for the publisher per device if (ApiInformation.IsTypePresent(typeof(HardwareIdentification).ToString())) { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer hardwareId = token.Id; HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5"); IBuffer hashed = hasher.HashData(hardwareId); string uniqueDeviceId = CryptographicBuffer.EncodeToHexString(hashed); return(uniqueDeviceId); } return(string.Empty); }
public MainPage() { this.InitializeComponent(); HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer hardwareId = token.Id; HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm("MD5"); IBuffer hashed = hasher.HashData(hardwareId); DeviceID = CryptographicBuffer.EncodeToHexString(hashed); DeviceName = GetHostName(); Setup(); SetupHardware(); }
public static string GetUniqueId() { string deviceUniqueId; ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; if (settings.Values.ContainsKey("DeviceUniqueId") == true) { deviceUniqueId = (string)settings.Values["DeviceUniqueId"]; } else { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer buffer = token.Id; byte[] bytes; using (var dataReader = DataReader.FromBuffer(buffer)) { bytes = new byte[buffer.Length]; dataReader.ReadBytes(bytes); } if (bytes.Length % 4 != 0) { throw new ArgumentException("Invalid hardware id"); } HardwareId[] hardwareIds = new HardwareId[bytes.Length / 4]; for (int index = 0; index < hardwareIds.Length; index++) { hardwareIds[index].type = (HardwareIdType)BitConverter.ToUInt16(bytes, index * 4); hardwareIds[index].value = BitConverter.ToUInt16(bytes, index * 4 + 2); } string cpu = hardwareIds.Where(i => i.type == HardwareIdType.Processor).FirstOrDefault().value.ToString(); string bios = hardwareIds.Where(i => i.type == HardwareIdType.SmBios).FirstOrDefault().value.ToString(); string mac = hardwareIds.Where(i => i.type == HardwareIdType.NetworkAdapter).FirstOrDefault().value.ToString(); deviceUniqueId = cpu + "-" + bios + "-" + mac; settings.Values["DeviceUniqueId"] = deviceUniqueId; } return(deviceUniqueId); }
public static async void RegisterWithMobileServices(string provider) { App.CurrentUser.Id = Guid.NewGuid().ToString(); App.CurrentUser.ProviderIdLong = App.MobileServicesUser.UserId; App.CurrentUser.ProviderIdShort = IdentityProviderParser.GetShortProvider(App.CurrentUser.ProviderIdLong); App.CurrentUser.Token = App.MobileServicesUser.MobileServiceAuthenticationToken; App.CurrentUser.IdentityProvider = IdentityProviderConverter.GetProvider(provider); string registrationId = String.Empty; try { Channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); Channel.PushNotificationReceived += NotificationReceived; HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); registrationId = CryptographicBuffer.EncodeToBase64String(token.Id); CurrentChannel.Id = Guid.NewGuid().ToString(); CurrentChannel.ChannelUri = Channel.Uri; CurrentChannel.DeviceType = Enums.DeviceType.Windows8; CurrentChannel.UserId = CurrentUser.ProviderIdLong; CurrentChannel.RegistrationId = registrationId; } catch (Exception ex) { HandleInsertChannelException(ex); } try { ApplicationDataManager.StoreValue(ApplicationConstants.UserKey, App.CurrentUser); await UsersTable.InsertAsync(App.CurrentUser); await ChannelsTable.InsertAsync(App.CurrentChannel); } catch (Exception ex) { HandleInsertChannelException(ex); } CompleteUserProfile(); RetrieveFriends(); }
private string ComputeDeviceId() { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Profile.HardwareIdentification")) { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); var hardwareId = token.Id; var dataReader = DataReader.FromBuffer(hardwareId); byte[] bytes = new byte[hardwareId.Length]; dataReader.ReadBytes(bytes); return(BitConverter.ToString(bytes).Replace("-", string.Empty)); } else { TrackingManagerHelper.Trace("Could not find HardwareIdentification to have device id"); } return("NA"); }
private String GetDeviceID() { HardwareToken hardwareToken = null; IBuffer tokenBuffer = null; DataReader tokenReader = null; byte[] token = null; string result = "Cannot retrieve hardware ID"; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(HardwareIDTypeApi)) { hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); tokenBuffer = hardwareToken.Id; tokenReader = DataReader.FromBuffer(tokenBuffer); token = new byte[tokenBuffer.Length]; tokenReader.ReadBytes(token); tokenReader.Dispose(); result = BitConverter.ToString(token).Replace("-", ""); } return(result); }
public static string GetASHWID() { if (string.IsNullOrEmpty(_ashwid)) { IBuffer id = null; HardwareToken ht = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null); id = ht.Id; var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(id); byte[] bytes = new byte[id.Length]; dataReader.ReadBytes(bytes); string s = BitConverter.ToString(bytes); if (!string.IsNullOrWhiteSpace(s)) { s = s.Replace("-", string.Empty); } _ashwid = s; } return(_ashwid); }
byte[] IPlatform.GetDefaultDeviceId() { var signature = new byte[8]; int index = 0; HardwareToken hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); using (DataReader dataReader = DataReader.FromBuffer(hardwareToken.Id)) { int offset = 0; while (offset < hardwareToken.Id.Length && index < 7) { var hardwareEntry = new byte[4]; dataReader.ReadBytes(hardwareEntry); byte componentID = hardwareEntry[0]; byte componentIDReserved = hardwareEntry[1]; if (componentIDReserved == 0) { switch (componentID) { // Per guidance in http://msdn.microsoft.com/en-us/library/windows/apps/jj553431 case 1: // CPU case 2: // Memory case 4: // Network Adapter case 9: // Bios signature[index++] = hardwareEntry[2]; signature[index++] = hardwareEntry[3]; break; default: break; } } offset += 4; } } return(signature); }
protected override DeviceId ComputeDeviceID() { DeviceId dId; if (preferredIdMethod == DeviceIdMethodInternal.winHardwareToken) { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); IBuffer hardwareId = token.Id; HashAlgorithmProvider hasher = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5); IBuffer hashed = hasher.HashData(hardwareId); string newId = CryptographicBuffer.EncodeToHexString(hashed); dId = new DeviceId(newId, DeviceIdMethodInternal.winHardwareToken); } else { //The other remaining option is either Guid or 'developer supplied' dId = CreateGUIDDeviceId(); } return(dId); }
private async void _tj_Click(object sender, RoutedEventArgs e) { if (_tb2.Text.Trim() == "") { await new MessageDialog("你好!至少说点什么呗?").ShowAsync(); return; } _tj.Visibility = Windows.UI.Xaml.Visibility.Collapsed; _tjing.IsActive = true; try { ClassHttp CH = new ClassHttp(); CH.HttpURL = URLSTR.jianyi; IDictionary <string, string> CS = new Dictionary <string, string>(); //可选参数,但如果要获取的地址不是网页,而是一个文件或图片,服务器一般默认配置不接受Post进而导致无法获取到。 //直接使用图片地址的,不要设置这个参数,避免使用Post方式,直接传递null。 HardwareToken hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); CS["hardwareToken_Id"] = Buffer2Base64(hardwareToken.Id); CS["daming"] = _tb1.Text; CS["jianyi"] = _tb2.Text; IDictionary <string, object> RE = await CH.LoadHttpText(CS); string re = RE["返回内容"].ToString(); await new MessageDialog(re).ShowAsync(); } catch (Exception exx) { } _tj.Visibility = Windows.UI.Xaml.Visibility.Visible; _tjing.IsActive = false; Frame.Navigate(typeof(PivotPage), null); }
public string GetAppSpecificHardwareId() { // http://msdn.microsoft.com/en-us/library/windows/apps/jj553431 string deviceId = ""; HardwareToken hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); using (DataReader dataReader = DataReader.FromBuffer(hardwareToken.Id)) { int offset = 0; while (offset < hardwareToken.Id.Length) { byte[] hardwareEntry = new byte[4]; dataReader.ReadBytes(hardwareEntry); // CPU ID of the processor || Size of the memory || Serial number of the disk device || BIOS if ((hardwareEntry[0] == 1 || hardwareEntry[0] == 2 || hardwareEntry[0] == 3 || hardwareEntry[0] == 9) && hardwareEntry[1] == 0) { deviceId += string.Format("{0}.{1}", hardwareEntry[2], hardwareEntry[3]); } offset += 4; } } return(deviceId); }
protected override void AddContentToMessage(List <byte> payload) { /*Part1 = "xx:xx:{1}:01:{0}:01:10:{2}" * Part2 = "yy:yy:{2}:{3}:{4}:{8}:02:01:00:02:{5}" * Part3 = "{10}:02:01:{6}:0b:{7}:04:04:00:15:00:00:80:{9}:00:09:01:01:06:00:52:65:6d:6f:76:65:01:02:01:01:0d:00:4d:75:74:65:20:43:61:6c:65:6e:64:61:72" * * 0 = Transaction ID = 2 bytes * 1 = Endpoint = 2 bytes b1:db * 2 = Message identifier = 16 bytes * 3 = Host identifier = 16 bytes * 4 = Timestamp (seconds from 1970-1-1) = 4 bytes * 5 = Length total message = 2 bytes * 6 = Description * 7 = Location * 8 = Duration meeting in minutes = 2 bytes * 9 = Details * 10 = Number items = 03 (no content) / 04 (content) */ List <byte> part1 = new List <byte>(0); List <byte> part2 = new List <byte>(0); List <byte> part3 = new List <byte>(0); //Add endpoint // AddInteger2Payload(part1, (Int32)Endpoint); part1.Add(0x01); //Transaction ID AddInteger2Payload(part1, Transaction); part1.Add(0x01); part1.Add(0x10); //Message identifier part1.AddRange(ID.ToByteArray()); part2.AddRange(ID.ToByteArray()); //Host identifier HardwareToken myToken = HardwareIdentification.GetPackageSpecificToken(null); Windows.Storage.Streams.IBuffer hardwareId = myToken.Id; byte[] hwIDBytes = System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.ToArray(hardwareId); byte[] truncArray = new byte[16]; Array.Copy(hwIDBytes, truncArray, truncArray.Length); part2.AddRange(truncArray); //Time stamp DateTime NowUTC = new DateTimeOffset(Time).UtcDateTime; uint Seconds = (uint)(NowUTC - new DateTime(1970, 1, 1)).TotalSeconds; byte[] bTime = BitConverter.GetBytes(Seconds); part2.AddRange(bTime); //Duration AddInteger2Payload(part2, Duration); part2.AddRange(new byte[] { 0x02, 0x01, 0x00, 0x02 }); //Length total message //Number items byte _nItems = 0x01; if (Description.Length > 0) { _nItems++; } if (Location.Length > 0) { _nItems++; } if (Details.Length > 0) { _nItems++; } part3.Add(_nItems); part3.AddRange(new byte[] { 0x02, 0x01 }); //Description AddString2Payload(part3, Description); //Location if (Location.Length > 0) { part3.AddRange(new byte[] { 0x0b }); AddString2Payload(part3, Location); } //Icon part3.AddRange(new byte[] { 0x04, 0x04, 0x00 }); part3.Add((byte)Icons.calender); part3.AddRange(new byte[] { 0x00, 0x00, 0x80 }); //Details if (Details.Length > 0) { part3.Add(0x03); AddString2Payload(part3, Details); } /* else * { * part3.Add(0x00); * }*/ //Add actions part3.AddRange(new byte[] { 0x00, 0x09, 0x01, 0x01, 0x06, 0x00, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x01, 0x02, 0x01, 0x01, 0x0d, 0x00, 0x4d, 0x75, 0x74, 0x65, 0x20, 0x43, 0x61, 0x6c, 0x65, 0x6e, 0x64, 0x61, 0x72 }); //Construct the message AddInteger2Payload(payload, part3.Count - 2); payload.AddRange(part3); payload.InsertRange(0, part2); InsertInteger2Payload(payload, 0, payload.Count); payload.InsertRange(0, part1); //InsertReverseInteger2Payload(payload, 0, payload.Count); }
/// <summary> /// 获取设备ID /// </summary> /// <returns>设备ID</returns> private static string GetDeviceId() { HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null); return(CryptographyHelper.Md5Encrypt(token.Id)); }
private async void Button_Click(object sender, RoutedEventArgs e) { string Sxz = ""; string Sren = ""; string Sxinxi = _xinxi.Text; if (_xingzhi01.IsChecked.Value) { Sxz = _xingzhi01.Content.ToString(); } if (_xingzhi02.IsChecked.Value) { Sxz = _xingzhi02.Content.ToString(); } if (_xingzhi03.IsChecked.Value) { Sxz = _xingzhi03.Content.ToString(); } if (_ren01.IsChecked.Value) { Sren = _ren01.Content.ToString(); } if (_ren02.IsChecked.Value) { Sren = _ren02.Content.ToString(); } if (_ren03.IsChecked.Value) { Sren = _ren03.Content.ToString(); } if (Sxz == "" || Sren == "") { await new MessageDialog("总要选择一下的嘛").ShowAsync(); return; } _tj.Visibility = Windows.UI.Xaml.Visibility.Collapsed; _tjing.IsActive = true; _tjing.Visibility = Windows.UI.Xaml.Visibility.Visible; try { ClassHttp CH = new ClassHttp(); CH.HttpURL = URLSTR.caidan; IDictionary <string, string> CS = new Dictionary <string, string>(); //可选参数,但如果要获取的地址不是网页,而是一个文件或图片,服务器一般默认配置不接受Post进而导致无法获取到。 //直接使用图片地址的,不要设置这个参数,避免使用Post方式,直接传递null。 HardwareToken hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); CS["hardwareToken_Id"] = Buffer2Base64(hardwareToken.Id); CS["xingzhi"] = Sxz; CS["ren"] = Sren; CS["xinxi"] = Sxinxi; IDictionary <string, object> RE = await CH.LoadHttpText(CS); string re = RE["返回内容"].ToString(); await new MessageDialog(re).ShowAsync(); } catch (Exception exx) { } _tj.Visibility = Windows.UI.Xaml.Visibility.Visible; _tjing.IsActive = false; _tjing.Visibility = Windows.UI.Xaml.Visibility.Collapsed; }