{"id":15552118,"url":"https://github.com/sonodima/wmipp","last_synced_at":"2025-04-23T20:23:15.884Z","repository":{"id":166569123,"uuid":"642032671","full_name":"sonodima/wmipp","owner":"sonodima","description":"WMI++ takes away the pain from interfacing with the Windows Management Instrumentation from C++","archived":false,"fork":false,"pushed_at":"2024-09-28T22:27:11.000Z","size":103,"stargazers_count":5,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-18T04:55:35.012Z","etag":null,"topics":["cpp","library","windows","wmi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sonodima.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-17T17:10:39.000Z","updated_at":"2024-09-27T19:56:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7f5b88f-0f27-4384-877b-a6b7a49debd7","html_url":"https://github.com/sonodima/wmipp","commit_stats":null,"previous_names":["sonodima/wmipp"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonodima%2Fwmipp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonodima%2Fwmipp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonodima%2Fwmipp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sonodima%2Fwmipp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sonodima","download_url":"https://codeload.github.com/sonodima/wmipp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250506868,"owners_count":21441865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","library","windows","wmi"],"created_at":"2024-10-02T14:09:14.585Z","updated_at":"2025-04-23T20:23:15.866Z","avatar_url":"https://github.com/sonodima.png","language":"C++","readme":"\u003ch1 align=\"center\"\u003eWMI++ 🤕\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/c%2B%2B-17+-orange\"/\u003e\n  \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\"/\u003e\n  \u003cimg src=\"https://repology.org/badge/version-for-repo/vcpkg/wmipp.svg\"/\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n\u003e WMI++ is a tiny-but-mighty header-only C++ library that takes away the pain of dealing with the Windows Management Instrumentation (WMI).\n\n## How To\n\n### Manual Install\n\nWMI++ is a __header-only__ library, which means you only need to include the necessary header file in your C++ code\n`(#include \u003cwmipp/wmipp.hxx\u003e)` to start using it. There is no need for any additional setup or installation.\n\nSimply copy the `wmipp` directory to your project's include directory and you're ready to go.\n\n### Install With Vcpkg\n\nIf you are using __Vcpkg__, you can quickly install WMI++ by running the following command:\n\n```sh\n./vcpkg install wmipp\n```\n\nOnce the installation is complete, you can include the necessary header file in your C++ code\n`(#include \u003cwmipp/wmipp.hxx\u003e)` and start using WMI++.\n\n### Usage\n\n#### Minimal Example\n\nRetrieve a specific property from a WMI query using WMI++.\n\nThe code executes a query that selects the `Name` property from the `Win32_Processor` class.\n\nThe result is accessed and stored as a `std::optional\u003cstd::string\u003e` in the `cpu_name` variable.\n\n```cpp\n#include \u003cwmipp/wmipp.hxx\u003e\n\nconst auto cpu_name = wmipp::Interface::Create()\n  -\u003eExecuteQuery(L\"SELECT Name FROM Win32_Processor\")\n  .GetProperty\u003cstd::string\u003e(L\"Name\");\n```\n\n#### Custom Path\n\nConnect to a specific WMI namespace by providing a custom path to the `wmipp::Interface::Create` method.\n\nReplace `\"CUSTOM_PATH_HERE\"` with the desired custom path, such as the namespace or machine path.\n\n```cpp\n#include \u003cwmipp/wmipp.hxx\u003e\n\nconst auto iface = wmipp::Interface::Create(\"CUSTOM_PATH_HERE\");\n```\n\n[MSDN](https://learn.microsoft.com/en-us/windows/win32/wmisdk/describing-the-location-of-a-wmi-object)\n\n#### Object Iteration\n\nIterate over multiple WMI objects returned by a query.\n\nThe code executes a query that selects the Model property from the `Win32_DiskDrive`.\n\nBecause this query may return more than one result _(with disks \u003e 1)_, you can choose to iterate\nall the returned objects in the result with range-based loops.\n\nWithin the loop, retrieve the `Model` property value of each object using the `GetProperty` function and store it in the `disk_model` variable.\n\n```cpp\n#include \u003cwmipp/wmipp.hxx\u003e\n\nfor (const auto\u0026 obj : wmipp::Interface::Create()-\u003eExecuteQuery(L\"SELECT Model FROM Win32_DiskDrive\")) {\n  const auto disk_model = obj.GetProperty\u003cstd::string\u003e(L\"Model\");\n}\n```\n\n#### Object Indexing\n\nSimilarly to iterating over multiple objects, you can use the `GetAt()` function or `[]` operator to access a\nspecific `Object` in the `QueryResult`.\n\nHere's an example of how you can get the `Model` of the second `DiskDrive`, if at least two drives are\navailable.\n\n```cpp\n#include \u003cwmipp/wmipp.hxx\u003e\n\nconst auto result : wmipp::Interface::Create()-\u003eExecuteQuery(L\"SELECT Model FROM Win32_DiskDrive\");\nif (result.Count() \u003e= 2) {\n  // Alternatively you can index the second element by doing [1]. These two operations are\n  // functionally identical and you can safely pick the one you like the most.\n  const auto disk_model = result.GetAt(1).GetProperty\u003cstd::string\u003e(L\"Model\");\n}\n```\n\n#### Reutilizing Interfaces\n\nIf you need to perform more than one query on the same path, you can utilize the same `Interface` to avoid creating\na new connection for each query.\n\nThe `Interface` instance will automatically get uninitialized when all other `Objects` and `QueryResults`\nusing it go out of scope.\n\n```cpp\n#include \u003cwmipp/wmipp.hxx\u003e\n\nconst auto iface = wmipp::Interface::Create();\nconst auto cpu_name = iface-\u003eExecuteQuery(L\"SELECT Name FROM Win32_Processor\")\n  .GetProperty\u003cstd::string\u003e(L\"Name\");\nconst auto user_name = iface-\u003eExecuteQuery(L\"SELECT UserName FROM Win32_ComputerSystem\")\n  .GetProperty\u003cstd::string\u003e(L\"UserName\");\n```\n\n\n\n## About Type Conversions\n\nCurrently there is support for the majority of the types you would usually need to query.\nThis is done by building a __variant_t__ and delegating it to handle the conversions.\nFurthermore, strings are converted from bstr_ts, and arrays are built from CComSafeArrays.\n\nHowever, support is currently not guaranteed for all types that can be present in VARIANTs.\n\nIf you need to use a type that is not automatically convertible, you can read the __variant_t__\nby calling the `GetProperty` method without specifying a template argument, and then you\ncan manipulate the returned object as you like.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonodima%2Fwmipp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonodima%2Fwmipp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonodima%2Fwmipp/lists"}