Borland together effecect for eclipse to start DOS window shielding

Source: Internet
Author: User

Borland together connector ECT for eclipseHow to enable DOS window shielding

By Guo shilongWhen Borland together connector ECT for eclipse is started, it is always the first time that a DOS window pops up. It is very unprofessional and uncomfortable ,. After carefully reading the startup process, the pop-up window should be executed for a togethersponect. bat batch file before the main program. This is the culprit of the DOS window pop-up. The first thought was to modify the batch processing file so that it could not display the DOS window. After checking the information online for half a day, it could not clear how to shield the DOS window. Use the familiar Win32 console program to solve the problem. There are two problems to be solved: one is our purpose, to shield the DOS window popped up by the batch processing program, and the other is the DOS window popped up by the console program itself. The second problem is well solved. Modify the compiler link option in the project properties-> link in VC and add the switch/subsystem: Windows/entry: Main, or add # pragma comment (linker, "/subsystem:/" Windows/"/entry:/" maincrtstartup/"") to the program /"") Link Option SwitchSpecify/subsystem. This link shows Windows how to run executable files. The console program is/subsystem: Other console programs are generally/subsystem: Windows. After selecting subsystem as "console", a console window is generated before Windows enters the executable file code (for example, maincrtstartup. If "Windows" is selected, the console window is not generated in the operating system. You can create the window for this type of application. All executable files have an entry point, which can be specified by/entry during link. By default, if the subsystem is "console", the entry point is maincrtstartup (ANSI) or wmaincrtstartuup (UNICODE), that is,/subsystem: console/entry: maincrtstartup (used by ANSI) or/subsystem: console/entry: wmaincrtstartuup (for Unicode ). Maincrtstartup or wmaincrtstartuup will call main or wmain;
If the subsystem is "Windows", the entry point is winmain (used by ANSI) or wwinmain (used by uincode), that is:/subsystem: Windows/entry: winmaincrtstartup (used by ANSI) or/sbusystem: windows/entry: wwinmaincrtstartup (used by uincode ). Winmaincrtstartup or wwinmaincrtstartup will call winmain or wwinmain.

Function Name Default
Maincrtstartup (or wmaincrtstartup) An application using/Subsystem: Console; CILSMain(OrWmain).
Winmaincrtstartup (or wwinmaincrtstartup) An application using/Subsystem: Windows; CILSWinmain(OrWwinmain), Which must be defined_ Stdcall.
_ Dllmaincrtstartup A dll; CILSDllmain, Which must be defined_ Stdcall, If it exists.
By default, the/subsystem and/entry switches match, that is, "console" corresponds to "maincrtstartup" or "wmaincrtstartup ", "Windows" corresponds to "winmain" or "wwinmain ". In order not to display the console window, add the following link option in the console Program # pragma comment (linker, "/subsystem:/" Windows/"/entry: /"maincrtstartup/" "), by manually modifying the link parameters to make them do not match, tell the system to" Windows "(do not generate a window, the program creates a window by itself) to process the console program. Shield the DOS window popped up by the batch processing program The method of shielding the DOS window popped up by the batch processing program is not complicated. The idea is to use the Windows API function CreateProcess to create a new process and execute togethereffecect. the bat batch file is created to hide the window. CreateProcess function prototype: Bool CreateProcess ( Lpctstr Lpapplicationname , Lptstr Lpcommandline , Lpsecurity_attributes Lpprocessattributes , Lpsecurity_attributes Lpthreadattributes , Bool Binherithandles , DWORD Dwcreationflags , Lpvoid Lpenvironment , Lpctstr Lpcurrentdirectory , Lpstartupinfo Lpstartupinfo , Lpprocess_information Lpprocessinformation );Several important parameters are briefly introduced, Lpapplicationname[Input parameter] is a string pointer pointing to a null string, which specifies the program to be executed. The string can be the full path of the program to be executed and the file name can also be partial names. If some names are used, the function uses the current directory of the current drive to specify the program to be executed. If the program name does not have a suffix, use the extension .exe. This parameter can be set to null. LpcommandlineParameter to specify the program to be executed. Lpcommandline[Input and output parameters] point to a string pointer of the command line to be executed ending with null. This parameter can be null. In this case, use the Parameter LpapplicationnameAs a command line. Binherithandles[Input parameter] If this parameter is set to true, each inherited handle of the calling process is inherited by the new process. If this parameter is set to false, it is not inherited. Dwcreationflags[Input parameter] this parameter is used to control process creation and priority. Here we are mainly concerned about the label create_no_window, which is used to create a windowless console program, it cannot be used with create_new_console or detached_process, it cannot be used in MS-DOS-based programs. This parameter is also used to control the priority of the new process. The default priority is normal_priority_class. Lpstartupinfo[Input parameter] this parameter is a pointer to the startuoinfo struct. This struct indicates the window status, desktop, standard handle, and appearance of the Main Window of the new process. Here, the parameters to be set in the startupingo structure are cb = sizeof (startupinfo), dwflags = startf_useshowwindow, and wshowwindow = sw_hide to hide the window by setting these parameters. LpprocessinformationThe [output parameter] is a pointer to the process_information struct. This struct is used to accept information about new processes. The handles in this struct must be closed with closehandle when they are not needed. For more information, see the msdn documentation. You can use this API function to hide a window in either of the following ways: DwcreationflagsSet the parameter value to create_no_window. LpstartupinfoSet the dwflags variable in the startuoinfo struct to startf_useshowwindow and the wshowwindow variable to sw_hide. Code Generation// Closedoswin. cpp # include "winuser. H"
# Include "windows. H"
# Include "closedoswin. H"
# Include "stdio. H"
# Include "string. H" # define cmdline "cmd.exe/C togethersponect. Bat" int main (INT argc, char ** argv ){
Tchar szcommand [] = _ T (using line );
Startupinfo;
Zeromemory (& startupinfo, sizeof (startupinfo ));
Startupinfo. cb = sizeof (startupinfo );
// Startupinfo. dwflags = startf_useshowwindow;
// Startupinfo. wshowwindow = sw_hide;
Process_information processinfo;
Zeromemory (& processinfo, sizeof (processinfo ));
If (! CreateProcess (null, szcommand, null, null, false, create_no_window/* normal_priority_class */, null, null, & startupinfo, & processinfo )){
Return false;
} Closehandle (processinfo. hthread); // close the newly created master thread handle
Closehandle (processinfo. hprocess); // close the newly created Process Handle
// Terminateprocess (processinfo. hprocess, 0); // waitforsingleobject (processinfo. hprocess, infinite); // wait until the new process ends.
Return 0;
} Usage(1)compile and generate closedoswin.exe
(2)put closedoswin.exe into the together installation directory
(3) Right-click to open the properties of the togetherarchhitect icon on the desktop (and or Start Menu program ).
(4) Replace ".../togethersponect. Bat" in the property-> target item with ".../closedoswin.exe" Executable File Download
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.