admin管理员组文章数量:1646323
#include <iostream>
#include <string>
#include <algorithm>
#include <windows.h>
//#include <stdio.h>
#include <conio.h>
#include <winreg.h>
#pragma comment(lib,"advapi32.lib")
//determine whether the current system is windows preinstallation environment.
bool IsWinPE()
{
HKEY hkey = NULL;
unsigned char buffer[260] = {0};
unsigned long dwsize = sizeof(buffer);
std::string strfind;
unsigned long iret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control",0,KEY_READ,&hkey);
if(iret != ERROR_SUCCESS)
return false;
iret = RegQueryValueEx(hkey,"SystemStartOptions",NULL,NULL,buffer,&dwsize);
if(iret != ERROR_SUCCESS)
{
RegCloseKey(hkey);
return false;
}
RegCloseKey(hkey);// get registry keys.
// next find '/MININT' flag.
strfind.assign((char *)buffer);
std::transform(strfind.begin(),strfind.end(),strfind.begin(),tolower);// to lowercase.
if((int)strfind.find("minint",0) > -1)// lowercase compare.
return true;//found it.
return false;
}
void main()
{
if(IsWinPE())
cout<<"current system is windows preinstallation environment."<<endl;
else
cout<<"current system is not windows pe."<<endl;
return ;
}
版权声明:本文标题:判断当前操作系统是否为pe环境 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1729441185a1201239.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论