Advertisement
Combreal

DismGetFeatureInfo.cpp

Apr 1st, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. //Couldn't find the DismAPI library on Windows ADK...
  2.  
  3. bool DismGetFeatureInfo(std::string passedFeature) //Microsoft-Windows-Subsystem-Linux
  4. {
  5.     bool enabled = false;
  6.     std::string status, command;
  7.     command = " /C dism /online /get-featureinfo /featurename: | findstr /R /C:\"State\" > featureStatus.txt";
  8.     command.insert(47,passedFeature);
  9.     ShellExecuteW(NULL, L"open", L"cmd.exe", stringToLPWSTR(command), NULL, SW_HIDE);
  10.     std::ifstream file("featureStatus.txt");
  11.     getline(file, status, '\n');
  12.     if(status.find("Enabled") != std::string::npos)
  13.     {
  14.         enabled = true;
  15.     }
  16.     file.close();
  17.     remove("featureStatus.txt");
  18.     return enabled;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement