Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Забанен


Сообщения: 793
Благодарности: 260

Профиль | Цитировать


Было дело, такая же задача подворачивалась.
Код: Выделить весь код
function Get-SystemFileCache {
  $SYSTEM_INFO = ($o = [Object].Assembly.GetType(
    'Microsoft.Win32.Win32Native'
  )).GetNestedType(
    'SYSTEM_INFO', [Reflection.BindingFlags]36
  ).InvokeMember(
    $null, [Reflection.BindingFlags]512, $null, $null, $null
  )

  $o.GetMethod(
    'GetSystemInfo', [Reflection.BindingFlags]40
  ).Invoke($null, ($si = [Object[]]@($SYSTEM_INFO)))

  $PageSize = $si[0].GetType().GetField(
    'dwPageSize', [Reflection.BindingFlags]36
  ).GetValue($si[0])

  $ptr = [Runtime.InteropServices.Marshal]::AllocHGlobal(36)
  if ([Regex].Assembly.GetType(
    'Microsoft.Win32.NativeMethods'
  ).GetMethod(
    'NtQuerySystemInformation'
  ).Invoke($null, @(21, $ptr, 36, 0)) -eq 0) {
    New-Object PSObject -Property @{
      CurrentSize = [Runtime.InteropServices.Marshal]::ReadInt32($ptr) / 1KB
      PeakSize = [Runtime.InteropServices.Marshal]::ReadInt32($ptr, 4) / 1KB
      MaximumWS = [Runtime.InteropServices.Marshal]::ReadInt32($ptr, 16) * $PageSize / 1KB
      MinimumWS = [Runtime.InteropServices.Marshal]::ReadInt32($ptr, 12) * $PageSize / 1KB
    } | Format-List
  }
  [Runtime.InteropServices.Marshal]::FreeHGlobal($ptr)
}
Это сообщение посчитали полезным следующие участники:

Отправлено: 14:17, 31-05-2015 | #2