Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is different between wmi and API

i work with c++ programming, I use an example for understanding main of my question.

Suppose, we want get current username in windows operation system, we can use follow code :

#include <windows.h>
#include <Lmcons.h>

char username[UNLEN+1];
DWORD username_len = UNLEN+1;
GetUserName(username, &username_len);

also, we can use wmi by follow the instruction explained on here and use Win32_ComputerSystem.UserName .

so, I hope you have fully understood, what's different between wmi and using api or any other way?

tank you for your response.

like image 214
Mr.DeveloperCplus Avatar asked Dec 07 '22 13:12

Mr.DeveloperCplus


2 Answers

disadvantage :

  • Speed (mainly disadvantage)
  • if user turn off wmi service, wmi doesn't work.

advantage :

  • Wraps the native API
  • richer data, if you use wmi, you can get rich data
  • standardized, all the 'entities' are represented in a standardized way

These are the most important issues for using wmi.

like image 193
Jack D Avatar answered Dec 30 '22 08:12

Jack D


Windows Management Instrumentation (WMI) is a set of specifications from Microsoft for consolidating the management of devices and applications in a network from Windows computing systems.

It is Microsoft implementation of Web-Based Enterprise Management. WMI - Services are installed on Windows OS, but the service can be turned off. So if user disabled the service you wont get any information about the system. It is just for reporting purpose.

Whereas the APIs are ways thru which the Microsoft provides the access to the information to local Application and some how you can also manipulate the information provided.

like image 42
anup kataria Avatar answered Dec 30 '22 06:12

anup kataria