/// <summary> /// Retrieves the names of all executable files that have defined console aliases. /// </summary> /// <returns>A StringCollection that contains one entry for each executable /// file that has console aliases.</returns> public static StringCollection GetAliasExes() { StringCollection strings = new StringCollection(); int length = GetAliasExesLength(); if (length > 0) { char[] buff = new char[length]; if (WinCon.GetConsoleAliasExes(buff, length) == 0) { throw new IOException("Unable to get alias exes", Marshal.GetLastWin32Error()); } // we have a buffer of nul-terminated strings // create individual strings int startIndex = 0; for (int i = 0; i < length; i++) { if (buff[i] == '\0') { string s = new string(buff, startIndex, i - startIndex); strings.Add(s); startIndex = i + 1; } } } return(strings); }