Skip to content

Instantly share code, notes, and snippets.

@kennykerr
Last active November 17, 2020 21:57
Embed
What would you like to do?
Reading the computer's serial number
#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());
}
@kennykerr
Copy link
Author

This example was inspired by Raymond Chen's post.

@DBJDBJ
Copy link

DBJDBJ commented Jan 9, 2018

The first two includes in Raymond's code where especially troublesome :)

@DBJDBJ
Copy link

DBJDBJ commented Jan 11, 2018

Out of sheer curiosity ... why the printf ? AFAIK in no code of yours, you use std::cout ?

@kennykerr
Copy link
Author

Mainly personal preference. Both are problematic in different ways. printf is always faster and often more concise.

@DBJDBJ
Copy link

DBJDBJ commented Jan 18, 2018

True indeed. Although printf() with a lot of arguments is tedious to get right, but then those examples are rare.

@iecompattest
Copy link

fdksjfklfd

@ackrumb
Copy link

ackrumb commented Nov 17, 2020

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