/** * Uses the {@link Kernel32#GetEnvironmentStrings()} to retrieve and * parse the current process environment * @return The current process environment as a {@link Map}. * @throws LastErrorException if failed to get or free the environment * data block * @see #getEnvironmentVariables(Pointer, long) */ public static Map<String,String> getEnvironmentVariables() { Pointer lpszEnvironmentBlock=Kernel32.INSTANCE.GetEnvironmentStrings(); if (lpszEnvironmentBlock == null) { throw new LastErrorException(Kernel32.INSTANCE.GetLastError()); } try { return getEnvironmentVariables(lpszEnvironmentBlock, 0L); } finally { if (!Kernel32.INSTANCE.FreeEnvironmentStrings(lpszEnvironmentBlock)) { throw new LastErrorException(Kernel32.INSTANCE.GetLastError()); } } }