Re: Using AttachConsole() to run GUI app in command prompt console

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rhett Gong [MSFT] (v-raygon_at_online.microsoft.com)
Date: 04/21/04


Date: Wed, 21 Apr 2004 07:12:12 GMT

After we discussed in your previous post, my thought truns to the entry point of an .exe. Since when we link an application, we use /SUBSYSTEM:CONSOLE to
indicate mainCRTStartup and use /SUBSYSTEM:WINDOWS to indicate WinMainCRTStartup. And we can use the linker option /ENTRY to specify the starting
address for an .exe, I thought if we could use "/SUBSYSTEM:WINDOWS /ENTRY:myMain" I do something like this (pseudo code):
//-----------------------------------------------------------------------------------
int __stdcall main(int argc, char **argv)
{
            If( argv == GUI)
            {
               // call
           hInst = GetModuleHandle(NULL);
           myWMain(hInst,NULL,NULL,1);
               //...........
             }
            else
            {
              // execute useful functions here
            }
        return 0;
}
//----------------------------------------------------------------------------------

Good Luck!
Rhett Gong [MSFT]
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks.



Relevant Pages

  • Re: Invoking Console Applications Program.Main from another project
    ... Is it possible to invoke the entry point of a console application project from another project. ... do I have to invoke the associated exe as per the post below ... initialization to happen, but it might not; ...
    (microsoft.public.dotnet.languages.csharp)
  • Softice newbie, packed Win32 exe debug question.
    ... have an exe packed with UPX compression. ... Then it immediately executes the binary ... without breaking at the entry-point - how do I break it at that entry ... I have spent several hours searching on Google/SI docs for info, ...
    (comp.lang.asm.x86)
  • Softice newbie, packed win32 exe question.
    ... have an exe packed with UPX compression. ... Then it immediately executes the binary ... without breaking at the entry-point - how do I break it at that entry ... I have spent several hours searching on Google/SI docs for info, ...
    (microsoft.public.development.device.drivers)
  • Re: Compile Problems
    ... You can also open the exe in notepad - near the top of the file is an entry ... know is that it isnt a .NET version as some of the functions, ...
    (microsoft.public.vb.general.discussion)
  • Re: using exe as dll
    ... >It is possible to export functions out of exe and then use it as ... >dll.What are the potential problems? ... the initial entry point goes instead to main or ... Thus, although you CAN load an executable as a DLL, as soon ...
    (microsoft.public.win32.programmer.kernel)