Module: Hiera::Util::Win32
- Extended by:
- Fiddle::Importer
- Includes:
- Fiddle::Win32Types
- Defined in:
- lib/hiera/util/win32.rb
Constant Summary collapse
- COMMON_APPDATA =
0x0023
- S_OK =
0x0
- MAX_PATH =
260
Class Method Summary collapse
Class Method Details
.get_common_appdata ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/hiera/util/win32.rb', line 30 def self.get_common_appdata # null terminated MAX_PATH string in wchar (i.e. 2 bytes per char) buffer = 0.chr * ((MAX_PATH + 1) * 2) result = SHGetFolderPathW(0, COMMON_APPDATA, 0, 0, buffer) raise "Could not find COMMON_APPDATA path - HRESULT: #{result}" unless result == S_OK buffer.force_encoding(Encoding::UTF_16LE).encode(Encoding::UTF_8).strip end |