Changeset 1567


Ignore:
Timestamp:
1/18/2010 6:49:46 AM (5 years ago)
Author:
lowjoel
Message:

Split the ConsoleWindow? class out of the KernelApi? class since it manages the lifetime of a ConsoleWindow?. Addresses #284: Eraser.Util rewrite

Location:
branches/eraser6/CodeReview/Eraser.Util
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview/Eraser.Util/Eraser.Util.csproj

    r1565 r1567  
    8282  </ItemGroup> 
    8383  <ItemGroup> 
     84    <Compile Include="ConsoleWindow.cs" /> 
    8485    <Compile Include="Power.cs" /> 
    8586    <Compile Include="NativeMethods\Gdi.cs" /> 
  • branches/eraser6/CodeReview/Eraser.Util/KernelApi.cs

    r1566 r1567  
    3232    public static class KernelApi 
    3333    { 
    34         /// <summary> 
    35         /// Allocates a new console for the calling process. 
    36         /// </summary> 
    37         /// <returns>If the function succeeds, the return value is nonzero. 
    38         ///  
    39         /// If the function fails, the return value is zero. To get extended error 
    40         /// information, call Marshal.GetLastWin32Error.</returns> 
    41         /// <remarks>A process can be associated with only one console, so the AllocConsole 
    42         /// function fails if the calling process already has a console. A process can 
    43         /// use the FreeConsole function to detach itself from its current console, then 
    44         /// it can call AllocConsole to create a new console or AttachConsole to attach 
    45         /// to another console. 
    46         ///  
    47         /// If the calling process creates a child process, the child inherits the 
    48         /// new console. 
    49         ///  
    50         /// AllocConsole initializes standard input, standard output, and standard error 
    51         /// handles for the new console. The standard input handle is a handle to the 
    52         /// console's input buffer, and the standard output and standard error handles 
    53         /// are handles to the console's screen buffer. To retrieve these handles, use 
    54         /// the GetStdHandle function. 
    55         ///  
    56         /// This function is primarily used by graphical user interface (GUI) application 
    57         /// to create a console window. GUI applications are initialized without a 
    58         /// console. Console applications are initialized with a console, unless they 
    59         /// are created as detached processes (by calling the CreateProcess function 
    60         /// with the DETACHED_PROCESS flag).</remarks> 
    61         [Obsolete] 
    62         public static bool AllocConsole() 
    63         { 
    64             return NativeMethods.AllocConsole(); 
    65         } 
    66  
    67         /// <summary> 
    68         /// Detaches the calling process from its console. 
    69         /// </summary> 
    70         /// <returns>If the function succeeds, the return value is nonzero. 
    71         ///  
    72         /// If the function fails, the return value is zero. To get extended error 
    73         /// information, call Marshal.GetLastWin32Error.</returns> 
    74         /// <remarks>A process can be attached to at most one console. If the calling 
    75         /// process is not already attached to a console, the error code returned is 
    76         /// ERROR_INVALID_PARAMETER (87). 
    77         ///  
    78         /// A process can use the FreeConsole function to detach itself from its 
    79         /// console. If other processes share the console, the console is not destroyed, 
    80         /// but the process that called FreeConsole cannot refer to it. A console is 
    81         /// closed when the last process attached to it terminates or calls FreeConsole. 
    82         /// After a process calls FreeConsole, it can call the AllocConsole function to 
    83         /// create a new console or AttachConsole to attach to another console.</remarks> 
    84         [Obsolete] 
    85         public static bool FreeConsole() 
    86         { 
    87             return NativeMethods.FreeConsole(); 
    88         } 
    89  
    9034        /// <summary> 
    9135        /// Retrieves the current value of the high-resolution performance counter. 
  • branches/eraser6/CodeReview/Eraser.Util/NativeMethods/Kernel.cs

    r1544 r1567  
    260260        } 
    261261 
     262        /// <summary> 
     263        /// Allocates a new console for the calling process. 
     264        /// </summary> 
     265        /// <returns>If the function succeeds, the return value is nonzero. 
     266        ///  
     267        /// If the function fails, the return value is zero. To get extended error 
     268        /// information, call Marshal.GetLastWin32Error.</returns> 
     269        /// <remarks>A process can be associated with only one console, so the AllocConsole 
     270        /// function fails if the calling process already has a console. A process can 
     271        /// use the FreeConsole function to detach itself from its current console, then 
     272        /// it can call AllocConsole to create a new console or AttachConsole to attach 
     273        /// to another console. 
     274        ///  
     275        /// If the calling process creates a child process, the child inherits the 
     276        /// new console. 
     277        ///  
     278        /// AllocConsole initializes standard input, standard output, and standard error 
     279        /// handles for the new console. The standard input handle is a handle to the 
     280        /// console's input buffer, and the standard output and standard error handles 
     281        /// are handles to the console's screen buffer. To retrieve these handles, use 
     282        /// the GetStdHandle function. 
     283        ///  
     284        /// This function is primarily used by graphical user interface (GUI) application 
     285        /// to create a console window. GUI applications are initialized without a 
     286        /// console. Console applications are initialized with a console, unless they 
     287        /// are created as detached processes (by calling the CreateProcess function 
     288        /// with the DETACHED_PROCESS flag).</remarks> 
    262289        [DllImport("Kernel32.dll", SetLastError = true)] 
    263290        [return: MarshalAs(UnmanagedType.Bool)] 
    264291        public static extern bool AllocConsole(); 
    265292 
     293        /// <summary> 
     294        /// Detaches the calling process from its console. 
     295        /// </summary> 
     296        /// <returns>If the function succeeds, the return value is nonzero. 
     297        ///  
     298        /// If the function fails, the return value is zero. To get extended error 
     299        /// information, call Marshal.GetLastWin32Error.</returns> 
     300        /// <remarks>A process can be attached to at most one console. If the calling 
     301        /// process is not already attached to a console, the error code returned is 
     302        /// ERROR_INVALID_PARAMETER (87). 
     303        ///  
     304        /// A process can use the FreeConsole function to detach itself from its 
     305        /// console. If other processes share the console, the console is not destroyed, 
     306        /// but the process that called FreeConsole cannot refer to it. A console is 
     307        /// closed when the last process attached to it terminates or calls FreeConsole. 
     308        /// After a process calls FreeConsole, it can call the AllocConsole function to 
     309        /// create a new console or AttachConsole to attach to another console.</remarks> 
    266310        [DllImport("Kernel32.dll", SetLastError = true)] 
    267311        [return: MarshalAs(UnmanagedType.Bool)] 
Note: See TracChangeset for help on using the changeset viewer.