title: Getting unique device ID in Win8 app
body: <p>I need to get an unique device identifier in Windows 8 application. I have few applications and I need to determine device ID that have one or more apps installed (e.g. a bonus for a gamer installing other game in the series). Using following methods provides me with per-app IDs which won't tell me that device have some other apps installed.</p>
  
  <p>I've tried three different approaches but they all return different UDIDs on the same PC.</p>
  
  <p>1) This was used before, since I needed unique id per app, now I need UDID, so it's predictably doesn't work for me:</p>
  
  <pre><code>GUID g;
  std::string ret;
  CoCreateGuid(&amp;g);
  Platform::Guid pg(g);
  std::string udid = WStringToUTF8(pg.ToString()-&gt;Data());
  </code></pre>
  
  <p>2) I've tried EasClienDeviceInformation, which was suggested as a sure thing, but got different results for 2 apps on the same PC:</p>
  
  <pre><code>EasClientDeviceInformation^ info = ref new EasClientDeviceInformation;
  ret = WStringToUTF8(info-&gt;Id.ToString()-&gt;Data());
  </code></pre>
  
  <p>3) And I've tried the commonly used way to get ASHWID, without any hope and it obviously shown different UDIDs:</p>
  
  <pre><code>auto token = Windows::System::Profile::HardwareIdentification::GetPackageSpecificToken(nullptr);
  ret = WStringToUTF8(Windows::Security::Cryptography::CryptographicBuffer::EncodeToBase64String(token-&gt;Id)-&gt;Data());
  _RPT1(_CRT_WARN, "TOKEN UDID IS %s \n", ret.c_str());
  </code></pre>
  
  <p>I know only about one option and it's to use MAC-address, but I'm not sure if it's a valid option. Users can have a PC where MAC-address could be changed or duplicated (I've heard of batches of chinese network adapters having the same address), or have a device without a network whatsoever (e.g. use a PC without a network adapter and connect to the internet using USB dongles).</p>
  
  <p>So the questions are:</p>
  
  <ol>
  <li><p>Did I do everything right, or I made a mistake that caused my examples to return wrong UDIDs?</p></li>
  <li><p>Am I right to assume that MAC-address is the only viable way to get a trutfully unique per-device identifier? I could've been inattentive and missed some obvious way.</p></li>
  <li><p>Am I wrong in my assumptions of MAC-address identification insecurities like those I've described above?</p></li>
  </ol>
  
  <hr>
  
  <p>UPD: I also would like to know the right way for WP8, while we're on it.</p>