looping trough logical drives
This commit is contained in:
parent
4baad8c5a2
commit
b95f35d40e
@ -1,4 +1,5 @@
|
|||||||
#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")
|
||||||
@ -8,6 +9,40 @@ using namespace std;
|
|||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
// Najde ldisky
|
||||||
|
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: ";
|
||||||
|
for (int i = 0; i < 26; i++)
|
||||||
|
{
|
||||||
|
if (drives & (1 << i))
|
||||||
|
{
|
||||||
|
ldisks.push_back(drive_names[i]);
|
||||||
|
cout << drive_names[i] << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
// Serial ID ldisku
|
||||||
|
DWORD disk_serialINT;
|
||||||
|
|
||||||
|
auto ldisks_count = size(ldisks);
|
||||||
|
ldisks_count = ldisks_count-1
|
||||||
|
|
||||||
|
|
||||||
|
if (!GetVolumeInformationA("C:\\", NULL, NULL, &disk_serialINT, NULL,
|
||||||
|
NULL, NULL, NULL))
|
||||||
|
{
|
||||||
|
std::cout << "Failed: " << GetLastError() << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Current directory volume serial numnber: " << std::hex << disk_serialINT << std::endl;
|
||||||
|
|
||||||
|
// IWbem HWIDs
|
||||||
cout << GetVideoCardDriverVersion() << endl;
|
cout << GetVideoCardDriverVersion() << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ std::string GetVideoCardDriverVersion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!FAILED(hr) && uReturned) {
|
if (!FAILED(hr) && uReturned) {
|
||||||
hr = pObj->Get(L"DriverVersion", 0, &var, NULL, NULL);
|
hr = pObj->Get(L"PNPDeviceID", 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