first version, bad output formats
This commit is contained in:
parent
b95f35d40e
commit
7f8f8a97ba
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,6 +2,6 @@
|
|||||||
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
|
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
.vs
|
||||||
/IWbemClassObject/Debug
|
/IWbemClassObject/Debug
|
||||||
/.vs
|
|
||||||
/IWbemClassObject/Release
|
/IWbemClassObject/Release
|
||||||
@ -1,5 +1,4 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <Wbemidl.h>
|
#include <Wbemidl.h>
|
||||||
#pragma comment(lib, "wbemuuid.lib")
|
#pragma comment(lib, "wbemuuid.lib")
|
||||||
@ -9,41 +8,53 @@ using namespace std;
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
// Najde ldisky
|
// Najde ldisky a zobrazi jejich SW serial no.
|
||||||
const char* drive_names[] = {"A:\\", "B:\\", "C:\\", "D:\\", "E:\\", "F:\\", "G:\\", "H:\\", "I:\\", "J:\\", "K:\\", "L:\\", "M:\\", "N:\\", "O:\\", "P:\\", "Q:\\", "R:\\", "S:\\", "T:\\", "U:\\", "V:\\", "W:\\", "X:\\", "Y:\\", "Z:\\"};
|
const char* drive_names[] = {"A:\\", "B:\\", "C:\\", "D:\\", "E:\\", "F:\\", "G:\\", "H:\\", "I:\\", "J:\\", "K:\\", "L:\\", "M:\\", "N:\\", "O:\\", "P:\\", "Q:\\", "R:\\", "S:\\", "T:\\", "U:\\", "V:\\", "W:\\", "X:\\", "Y:\\", "Z:\\"};
|
||||||
|
|
||||||
std::vector< const char* > ldisks;
|
|
||||||
|
|
||||||
DWORD drives = GetLogicalDrives();
|
DWORD drives = GetLogicalDrives();
|
||||||
cout << "Connected logical drives: ";
|
DWORD disk_serialINT;
|
||||||
|
cout << "Connected logical drives: " << endl;
|
||||||
for (int i = 0; i < 26; i++)
|
for (int i = 0; i < 26; i++)
|
||||||
{
|
{
|
||||||
if (drives & (1 << i))
|
if (drives & (1 << i))
|
||||||
{
|
{
|
||||||
ldisks.push_back(drive_names[i]);
|
if (GetVolumeInformationA(drive_names[i], NULL, NULL, &disk_serialINT, NULL,
|
||||||
cout << drive_names[i] << " ";
|
NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
cout << drive_names[i] << " VolumeID: " << hex << disk_serialINT << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << drive_names[i] << " VolumeID: " << "Empty" << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
// Serial ID ldisku
|
// Najde hardware serial no a vyrobce vsech komponentu
|
||||||
DWORD disk_serialINT;
|
cout << "--Win32_Processor--" << endl << "ProcessorID: " << GetHWIDs("Win32_Processor", L"ProcessorID") << endl;
|
||||||
|
cout << "UniqueID: " << GetHWIDs("Win32_Processor", L"UniqueID") << endl;
|
||||||
|
cout << "Manufacturer: " << GetHWIDs("Win32_Processor", L"Manufacturer") << endl << endl;
|
||||||
|
|
||||||
auto ldisks_count = size(ldisks);
|
cout << "--Win32_OnBoardDevice--" << endl << "SerialNumber: " << GetHWIDs("Win32_OnBoardDevice", L"SerialNumber") << endl;
|
||||||
ldisks_count = ldisks_count-1
|
cout << "Manufacturer: " << GetHWIDs("Win32_OnBoardDevice", L"Manufacturer") << endl << endl;
|
||||||
|
|
||||||
|
cout << "--Win32_BaseBoard--" << endl << "SerialNumber: " << GetHWIDs("Win32_BaseBoard", L"SerialNumber") << endl;
|
||||||
|
cout << "Manufacturer: " << GetHWIDs("Win32_BaseBoard", L"Manufacturer") << endl << endl;
|
||||||
|
|
||||||
if (!GetVolumeInformationA("C:\\", NULL, NULL, &disk_serialINT, NULL,
|
cout << "--Win32_BIOS--" << endl << "SerialNumber: " << GetHWIDs("Win32_BIOS", L"SerialNumber") << endl;
|
||||||
NULL, NULL, NULL))
|
cout << "Manufacturer: " << GetHWIDs("Win32_BIOS", L"Manufacturer") << endl << endl;
|
||||||
{
|
|
||||||
std::cout << "Failed: " << GetLastError() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Current directory volume serial numnber: " << std::hex << disk_serialINT << std::endl;
|
cout << "--Win32_NetworkAdapter--" << endl << "MACAddress: " << GetHWIDs("Win32_NetworkAdapter", L"MACAddress") << endl;
|
||||||
|
cout << "Manufacturer: " << GetHWIDs("Win32_NetworkAdapter", L"Manufacturer") << endl << endl;
|
||||||
|
|
||||||
// IWbem HWIDs
|
cout << "--Win32_DiskDrive--" << endl << "SerialNumber: " << GetHWIDs("Win32_DiskDrive", L"SerialNumber") << endl;
|
||||||
cout << GetVideoCardDriverVersion() << endl;
|
cout << "Manufacturer: " << GetHWIDs("Win32_DiskDrive", L"Manufacturer") << endl << endl;
|
||||||
|
|
||||||
return 0;
|
cout << "--Win32_VideoController--" << endl << "PNPDeviceID: " << GetHWIDs("Win32_VideoController", L"PNPDeviceID") << endl;
|
||||||
|
cout << "Manufacturer: " << GetHWIDs("Win32_VideoController", L"Manufacturer") << endl << endl;
|
||||||
|
|
||||||
|
cin.ignore();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
std::string GetVideoCardDriverVersion() {
|
std::string GetHWIDs(std::string table, LPCWSTR column) {
|
||||||
std::string retvalue = "";
|
std::string retvalue = "";
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
@ -29,7 +29,11 @@ std::string GetVideoCardDriverVersion() {
|
|||||||
NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_DEFAULT);
|
NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_DEFAULT);
|
||||||
|
|
||||||
BSTR bstrWQL = SysAllocString(L"WQL");
|
BSTR bstrWQL = SysAllocString(L"WQL");
|
||||||
BSTR bstrPath = SysAllocString(L"select * from Win32_VideoController");
|
//mrdka zasrana POMOC datatypy s vyterem prdele
|
||||||
|
std::string wqlquery = "select * from " + table;
|
||||||
|
std::wstring wide_string = std::wstring(wqlquery.begin(), wqlquery.end());
|
||||||
|
const wchar_t* result = wide_string.c_str();
|
||||||
|
BSTR bstrPath = SysAllocString(result);
|
||||||
IEnumWbemClassObject* pEnum;
|
IEnumWbemClassObject* pEnum;
|
||||||
hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
||||||
|
|
||||||
@ -41,7 +45,7 @@ std::string GetVideoCardDriverVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!FAILED(hr) && uReturned) {
|
if (!FAILED(hr) && uReturned) {
|
||||||
hr = pObj->Get(L"PNPDeviceID", 0, &var, NULL, NULL);
|
hr = pObj->Get(column, 0, &var, NULL, NULL);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
char str[MAX_PATH];
|
char str[MAX_PATH];
|
||||||
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, str, sizeof(str), NULL, NULL);
|
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, str, sizeof(str), NULL, NULL);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user