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.
|
||||
################################################################################
|
||||
|
||||
.vs
|
||||
/IWbemClassObject/Debug
|
||||
/.vs
|
||||
/IWbemClassObject/Release
|
||||
@ -1,5 +1,4 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <Windows.h>
|
||||
#include <Wbemidl.h>
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
@ -9,41 +8,53 @@ using namespace std;
|
||||
|
||||
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:\\"};
|
||||
|
||||
std::vector< const char* > ldisks;
|
||||
|
||||
DWORD drives = GetLogicalDrives();
|
||||
cout << "Connected logical drives: ";
|
||||
DWORD disk_serialINT;
|
||||
cout << "Connected logical drives: " << endl;
|
||||
for (int i = 0; i < 26; i++)
|
||||
{
|
||||
if (drives & (1 << i))
|
||||
{
|
||||
ldisks.push_back(drive_names[i]);
|
||||
cout << drive_names[i] << " ";
|
||||
if (GetVolumeInformationA(drive_names[i], NULL, NULL, &disk_serialINT, NULL,
|
||||
NULL, NULL, NULL))
|
||||
{
|
||||
cout << drive_names[i] << " VolumeID: " << hex << disk_serialINT << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << drive_names[i] << " VolumeID: " << "Empty" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
// Serial ID ldisku
|
||||
DWORD disk_serialINT;
|
||||
// Najde hardware serial no a vyrobce vsech komponentu
|
||||
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);
|
||||
ldisks_count = ldisks_count-1
|
||||
cout << "--Win32_OnBoardDevice--" << endl << "SerialNumber: " << GetHWIDs("Win32_OnBoardDevice", L"SerialNumber") << endl;
|
||||
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,
|
||||
NULL, NULL, NULL))
|
||||
{
|
||||
std::cout << "Failed: " << GetLastError() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
cout << "--Win32_BIOS--" << endl << "SerialNumber: " << GetHWIDs("Win32_BIOS", L"SerialNumber") << endl;
|
||||
cout << "Manufacturer: " << GetHWIDs("Win32_BIOS", L"Manufacturer") << endl << endl;
|
||||
|
||||
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 << GetVideoCardDriverVersion() << endl;
|
||||
cout << "--Win32_DiskDrive--" << endl << "SerialNumber: " << GetHWIDs("Win32_DiskDrive", L"SerialNumber") << 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 = "";
|
||||
|
||||
HRESULT hr;
|
||||
@ -29,7 +29,11 @@ std::string GetVideoCardDriverVersion() {
|
||||
NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_DEFAULT);
|
||||
|
||||
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;
|
||||
hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
||||
|
||||
@ -41,7 +45,7 @@ std::string GetVideoCardDriverVersion() {
|
||||
}
|
||||
|
||||
if (!FAILED(hr) && uReturned) {
|
||||
hr = pObj->Get(L"PNPDeviceID", 0, &var, NULL, NULL);
|
||||
hr = pObj->Get(column, 0, &var, NULL, NULL);
|
||||
if (SUCCEEDED(hr)) {
|
||||
char str[MAX_PATH];
|
||||
WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, str, sizeof(str), NULL, NULL);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user