Reading the computer's serial number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "winrt/Windows.System.Profile.SystemManufacturers.h" | |
using namespace winrt::Windows::System::Profile::SystemManufacturers; | |
int main() | |
{ | |
winrt::init_apartment(); | |
printf("Serial number = %ls\n", SmbiosInformation::SerialNumber().c_str()); | |
} |
The first two includes in Raymond's code where especially troublesome :)
Out of sheer curiosity ... why the printf
? AFAIK in no code of yours, you use std::cout
?
Mainly personal preference. Both are problematic in different ways. printf
is always faster and often more concise.
True indeed. Although printf()
with a lot of arguments is tedious to get right, but then those examples are rare.
fdksjfklfd
Question: Why do you omit the
winrt::init_apartment();
...
winrt::clear_factory_cache();
winrt::uninit_apartment();
or more importantly, why does he include them?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example was inspired by Raymond Chen's post.