Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

talloc.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1985 - 1999, Microsoft Corporation 00004 00005 Module Name: 00006 00007 talloc.c 00008 00009 Abstract: 00010 00011 Test program for AllocConsole and FreeConsole 00012 00013 Author: 00014 00015 Therese Stowell (thereses) July-15-1991 00016 00017 Revision History: 00018 00019 NOTE: this test must be linked as a gui app 00020 00021 --*/ 00022 00023 #include "precomp.h" 00024 #pragma hdrstop 00025 #pragma hdrstop 00026 00027 CHAR String[11] = "teststring"; 00028 00029 HANDLE 00030 TestProcess( 00031 IN DWORD CreationFlags, 00032 IN LPSTR AppName 00033 ) 00034 { 00035 STARTUPINFO StartupInfo; 00036 PROCESS_INFORMATION ProcessInformation; 00037 SECURITY_ATTRIBUTES ProcessAttributes; 00038 00039 ProcessAttributes.nLength = sizeof(SECURITY_ATTRIBUTES); 00040 ProcessAttributes.lpSecurityDescriptor = NULL; 00041 ProcessAttributes.bInheritHandle = TRUE; 00042 00043 StartupInfo.cb = sizeof(StartupInfo); 00044 StartupInfo.lpReserved = "UsedByShell"; 00045 StartupInfo.lpDesktop = "TheresesDesktop"; 00046 StartupInfo.lpTitle = "TheresesTestTitle"; 00047 StartupInfo.dwX = 0; 00048 StartupInfo.dwY = 1; 00049 StartupInfo.dwXSize = 80; 00050 StartupInfo.dwYSize = 50; 00051 StartupInfo.dwFlags = 0;//STARTF_SHELLOVERRIDE; 00052 StartupInfo.wShowWindow = 0;//SW_SHOWDEFAULT; 00053 StartupInfo.lpReserved2 = 0; 00054 StartupInfo.cbReserved2 = 0; 00055 00056 if ( !CreateProcess( 00057 NULL, 00058 AppName, 00059 &ProcessAttributes, 00060 NULL, 00061 TRUE, 00062 CreationFlags, 00063 NULL, 00064 NULL, 00065 &StartupInfo, 00066 &ProcessInformation 00067 ) ) 00068 DbgPrint("TALLOC: CreateProcess failed\n"); 00069 return ProcessInformation.hProcess; 00070 } 00071 00072 BOOL 00073 CallConsoleApi( 00074 IN WORD y 00075 ) 00076 { 00077 CHAR_INFO Buffer[10]; 00078 COORD BufferSize; 00079 COORD BufferCoord; 00080 SMALL_RECT WriteRegion; 00081 int i; 00082 BOOL Success; 00083 00084 BufferSize.X = 10; 00085 BufferSize.Y = 1; 00086 BufferCoord.X = 0; 00087 BufferCoord.Y = 0; 00088 WriteRegion.Left = 0; 00089 WriteRegion.Top = y; 00090 WriteRegion.Right = 14; 00091 WriteRegion.Bottom = y; 00092 for (i=0;i<10;i++) { 00093 Buffer[i].Char.AsciiChar = String[i]; 00094 Buffer[i].Attributes = y; 00095 } 00096 Success = WriteConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE), 00097 Buffer, 00098 BufferSize, 00099 BufferCoord, 00100 &WriteRegion 00101 ); 00102 return Success; 00103 } 00104 00105 DWORD 00106 main( 00107 int argc, 00108 char *argv[], 00109 char *envp[] 00110 ) 00111 { 00112 if (CallConsoleApi(5)) 00113 DbgPrint("TALLOC: CallConsoleApi succeeded\n"); 00114 00115 if (!AllocConsole()) 00116 DbgPrint("TALLOC: AllocConsole failed\n"); 00117 00118 if (!CallConsoleApi(5)) 00119 DbgPrint("TALLOC: CallConsoleApi failed\n"); 00120 00121 if (AllocConsole()) 00122 DbgPrint("TALLOC: AllocConsole succeeded\n"); 00123 00124 TestProcess(DETACHED_PROCESS,"tdetach"); 00125 00126 TestProcess(0,"tattach"); 00127 00128 Sleep(10000); 00129 00130 if (!CallConsoleApi(6)) 00131 DbgPrint("TALLOC: CallConsoleApi failed\n"); 00132 00133 if (!FreeConsole()) 00134 DbgPrint("TALLOC: FreeConsole failed\n"); 00135 00136 if (CallConsoleApi(5)) 00137 DbgPrint("TALLOC: CallConsoleApi succeeded\n"); 00138 00139 if (FreeConsole()) 00140 DbgPrint("TALLOC: FreeConsole succeeded\n"); 00141 }

Generated on Sat May 15 19:41:57 2004 for test by doxygen 1.3.7