Module: Chef::Mixin::WindowsEnvHelper
- Includes:
- WideString, ReservedNames::Win32::API::System
- Defined in:
- lib/chef/mixin/windows_env_helper.rb
Constant Summary collapse
- HWND_BROADCAST =
0xffff
- WM_SETTINGCHANGE =
0x001A
- SMTO_BLOCK =
0x0001
- SMTO_ABORTIFHUNG =
0x0002
- SMTO_NOTIMEOUTIFNOTHUNG =
0x0008
Constants included from ReservedNames::Win32::API::System
ReservedNames::Win32::API::System::PRODUCT_BUSINESS, ReservedNames::Win32::API::System::PRODUCT_BUSINESS_N, ReservedNames::Win32::API::System::PRODUCT_CLUSTER_SERVER, ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER, ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER_CORE, ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER_CORE_V, ReservedNames::Win32::API::System::PRODUCT_DATACENTER_SERVER_V, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_E, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_N, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_CORE, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_CORE_V, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_IA64, ReservedNames::Win32::API::System::PRODUCT_ENTERPRISE_SERVER_V, ReservedNames::Win32::API::System::PRODUCT_HOME_BASIC, ReservedNames::Win32::API::System::PRODUCT_HOME_BASIC_E, ReservedNames::Win32::API::System::PRODUCT_HOME_BASIC_N, ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM, ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM_E, ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM_N, ReservedNames::Win32::API::System::PRODUCT_HOME_PREMIUM_SERVER, ReservedNames::Win32::API::System::PRODUCT_HOME_SERVER, ReservedNames::Win32::API::System::PRODUCT_HYPERV, ReservedNames::Win32::API::System::PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT, ReservedNames::Win32::API::System::PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING, ReservedNames::Win32::API::System::PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY, ReservedNames::Win32::API::System::PRODUCT_PROFESSIONAL, ReservedNames::Win32::API::System::PRODUCT_PROFESSIONAL_E, ReservedNames::Win32::API::System::PRODUCT_PROFESSIONAL_N, ReservedNames::Win32::API::System::PRODUCT_SB_SOLUTION_SERVER, ReservedNames::Win32::API::System::PRODUCT_SERVER_FOR_SMALLBUSINESS, ReservedNames::Win32::API::System::PRODUCT_SERVER_FOR_SMALLBUSINESS_V, ReservedNames::Win32::API::System::PRODUCT_SERVER_FOUNDATION, ReservedNames::Win32::API::System::PRODUCT_SMALLBUSINESS_SERVER, ReservedNames::Win32::API::System::PRODUCT_SOLUTION_EMBEDDEDSERVER, ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER, ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER_CORE, ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER_CORE_V, ReservedNames::Win32::API::System::PRODUCT_STANDARD_SERVER_V, ReservedNames::Win32::API::System::PRODUCT_STARTER, ReservedNames::Win32::API::System::PRODUCT_STARTER_E, ReservedNames::Win32::API::System::PRODUCT_STARTER_N, ReservedNames::Win32::API::System::PRODUCT_STORAGE_ENTERPRISE_SERVER, ReservedNames::Win32::API::System::PRODUCT_STORAGE_EXPRESS_SERVER, ReservedNames::Win32::API::System::PRODUCT_STORAGE_STANDARD_SERVER, ReservedNames::Win32::API::System::PRODUCT_STORAGE_WORKGROUP_SERVER, ReservedNames::Win32::API::System::PRODUCT_ULTIMATE, ReservedNames::Win32::API::System::PRODUCT_ULTIMATE_E, ReservedNames::Win32::API::System::PRODUCT_ULTIMATE_N, ReservedNames::Win32::API::System::PRODUCT_UNDEFINED, ReservedNames::Win32::API::System::PRODUCT_WEB_SERVER, ReservedNames::Win32::API::System::PRODUCT_WEB_SERVER_CORE, ReservedNames::Win32::API::System::SM_SERVERR2, ReservedNames::Win32::API::System::VER_NT_DOMAIN_CONTROLLER, ReservedNames::Win32::API::System::VER_NT_SERVER, ReservedNames::Win32::API::System::VER_NT_WORKSTATION, ReservedNames::Win32::API::System::VER_SUITE_BACKOFFICE, ReservedNames::Win32::API::System::VER_SUITE_BLADE, ReservedNames::Win32::API::System::VER_SUITE_COMPUTE_SERVER, ReservedNames::Win32::API::System::VER_SUITE_DATACENTER, ReservedNames::Win32::API::System::VER_SUITE_EMBEDDEDNT, ReservedNames::Win32::API::System::VER_SUITE_ENTERPRISE, ReservedNames::Win32::API::System::VER_SUITE_PERSONAL, ReservedNames::Win32::API::System::VER_SUITE_SINGLEUSERTS, ReservedNames::Win32::API::System::VER_SUITE_SMALLBUSINESS, ReservedNames::Win32::API::System::VER_SUITE_SMALLBUSINESS_RESTRICTED, ReservedNames::Win32::API::System::VER_SUITE_STORAGE_SERVER, ReservedNames::Win32::API::System::VER_SUITE_TERMINAL, ReservedNames::Win32::API::System::VER_SUITE_WH_SERVER
Instance Method Summary collapse
Methods included from WideString
#utf8_to_wide, #wide_to_utf8, #wstring
Instance Method Details
#broadcast_env_change ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/chef/mixin/windows_env_helper.rb', line 42 def broadcast_env_change flags = SMTO_BLOCK | SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG # for why two calls, see: # http://stackoverflow.com/questions/4968373/why-doesnt-sendmessagetimeout-update-the-environment-variables if SendMessageTimeoutA(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string("Environment").address, flags, 5000, nil) == 0 Chef::ReservedNames::Win32::Error.raise! end if SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, FFI::MemoryPointer.from_string( utf8_to_wide("Environment") ).address, flags, 5000, nil) == 0 Chef::ReservedNames::Win32::Error.raise! end end |
#expand_path(path) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/chef/mixin/windows_env_helper.rb', line 56 def (path) # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724265%28v=vs.85%29.aspx # Max size of env block on windows is 32k buf = 0.chr * 32 * 1024 if ExpandEnvironmentStringsA(path, buf, buf.length) == 0 Chef::ReservedNames::Win32::Error.raise! end buf.strip end |