mirror of
https://github.com/janbodnar/Windows-API-examples.git
synced 2024-11-24 11:25:30 +00:00
Create computer_name.c
This commit is contained in:
parent
220f68b976
commit
a6f48c2709
19
system/computer_name.c
Normal file
19
system/computer_name.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int wmain(void) {
|
||||
|
||||
wchar_t computerName[MAX_COMPUTERNAME_LENGTH + 1];
|
||||
DWORD size = sizeof(computerName) / sizeof(computerName[0]);
|
||||
|
||||
int r = GetComputerNameW(computerName, &size);
|
||||
|
||||
if (r == 0) {
|
||||
wprintf(L"Failed to get computer name %ld", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
wprintf(L"Computer name: %ls\n", computerName);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user