Класс Win32_OperatingSystem
WMi имеет 4 свойства, которые сообщают о состоянии DEP
- DataExecutionPrevention_Available
- DataExecutionPrevention_32BitApplications
- DataExecutionPrevention_Drivers
- DataExecutionPrevention_SupportPolicy
Прочтите документацию MSDN об этих свойствах, чтобы увидеть описание.
Проверьте этот пример приложения
{$APPTYPE CONSOLE}
uses
SysUtils,
ActiveX,
ComObj,
Variants;
function DEPStatus(Status : integer) : string;
begin
case Status of
0 : Result:='Always Off';
1 : Result:='DEP is turned off for all 32-bit applications on the computer with no exceptions. This setting is not available for the user interface.';
2 : Result:='DEP is enabled for all 32-bit applications on the computer. This setting is not available for the user interface.';
3 : Result:='DEP is enabled by default for all 32-bit applications. A user or administrator can explicitly remove support for a 32-bit application by adding the application to an exceptions list.';
else
Result:='unknown';
end;
end;
procedure GetDEPStatusInfo;
const
WbemUser ='';
WbemPassword ='';
WbemComputer ='localhost';
wbemFlagForwardOnly = $00000020;
var
FSWbemLocator : OLEVariant;
FWMIService : OLEVariant;
FWbemObjectSet: OLEVariant;
FWbemObject : OLEVariant;
oEnum : IEnumvariant;
iValue : LongWord;
begin;
FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_OperatingSystem','WQL',wbemFlagForwardOnly);
oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
if oEnum.Next(1, FWbemObject, iValue) = 0 then
begin
Writeln(Format('DataExecutionPrevention_32BitApplications %s',[FWbemObject.DataExecutionPrevention_32BitApplications]));// Boolean
Writeln(Format('DataExecutionPrevention_Available %s',[FWbemObject.DataExecutionPrevention_Available]));// Boolean
Writeln(Format('DataExecutionPrevention_Drivers %s',[FWbemObject.DataExecutionPrevention_Drivers]));// Boolean
Writeln(Format('DataExecutionPrevention_SupportPolicy %s',[FWbemObject.DataExecutionPrevention_SupportPolicy]));// Uint8
Writeln(DEPStatus(FWbemObject.DataExecutionPrevention_SupportPolicy));
end;
end;
begin
try
CoInitialize(nil);
try
GetDEPStatusInfo;
finally
CoUninitialize;
end;
except
on E:EOleException do
Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode]));
on E:Exception do
Writeln(E.Classname, ':', E.Message);
end;
Writeln('Press Enter to exit');
Readln;
end.