예제 #1
0
        public static string GetAlias(string Source, string ExeName)
        {
            // The only reliable way to allocate enough space is to the
            // combined length for all aliases.
            int length = GetAliasesLength(ExeName);

            if (length == 0)
            {
                return(string.Empty);
            }

            char[] buff = new char[length];
            int    rslt = WinCon.GetConsoleAlias(Source, buff, buff.Length, ExeName);

            if (rslt == 0)
            {
                throw new IOException("Unable to get alias", Marshal.GetLastWin32Error());
            }
            return(new string(buff));
        }