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