游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3725|回复: 8

请问 关于WIN32程序的问题?

[复制链接]

4

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2004-9-9 22:24:00 | 显示全部楼层 |阅读模式
VC里有 WIN 32 APPLICATION 和 WIN32 CONSOLE APPLICATION,
即WIN 32 程序 和 WIN 32 控制台程序。
请问它们有什么表面的区别和本质上的区别?

28

主题

685

帖子

703

积分

高级会员

Rank: 4

积分
703
发表于 2004-9-9 23:20:00 | 显示全部楼层

看vc里面的wincrtstart的原代码即可知道。

rt
我不贴了。

18

主题

573

帖子

573

积分

高级会员

Rank: 4

积分
573
发表于 2004-9-10 00:50:00 | 显示全部楼层

Re:请问 关于WIN32程序的问题?

首先他们都是运行在win32平台上的,其次就是一个是windows程序,使用的是WinMain,另一个是windows平台的dos程序,使用的main,可以了吗?

28

主题

685

帖子

703

积分

高级会员

Rank: 4

积分
703
发表于 2004-9-10 07:37:00 | 显示全部楼层

还是贴一下吧,其实每个程序都是调用的下面的这个函数


#ifdef _WINMAIN_

#ifdef WPRFLAG
int wWinMainCRTStartup(
#else  /* WPRFLAG */
int WinMainCRTStartup(
#endif  /* WPRFLAG */

#else  /* _WINMAIN_ */

#ifdef WPRFLAG
int wmainCRTStartup(
#else  /* WPRFLAG */
int mainCRTStartup(
#endif  /* WPRFLAG */

#endif  /* _WINMAIN_ */
        void
        )
{
        int argc;   /* three standard arguments to main */
        _TSCHAR **argv;
        _TSCHAR **envp;

        int argret;
        int mainret;
        int managedapp;

#ifdef _WINMAIN_
        _TUCHAR *lpszCommandLine;
        STARTUPINFO StartupInfo;
        BOOL inDoubleQuote=FALSE;
#endif  /* _WINMAIN_ */

        _startupinfo    startinfo;

        /*
         * Determine if this is a managed application
         */
        managedapp = check_managed_app();

        /*
         * Guard the initialization code and the call to user's main, or
         * WinMain, function in a __try/__except statement.
         */

        __try {
            /*
             * Set __app_type properly
             */
#ifdef _WINMAIN_
            __set_app_type(_GUI_APP);
#else  /* _WINMAIN_ */
            __set_app_type(_CONSOLE_APP);
#endif  /* _WINMAIN_ */

            /*
             * Mark this module as an EXE file so that atexit/_onexit
             * will do the right thing when called, including for C++
             * d-tors.
             */
            __onexitbegin = __onexitend = (_PVFV *)(-1);

            /*
             * Propogate the _fmode and _commode variables to the DLL
             */
            *_IMP___FMODE = _fmode;
            *_IMP___COMMODE = _commode;

#ifdef _M_IX86
            /*
             * Set the local copy of the Pentium FDIV adjustment flag
             */

            _adjust_fdiv = * _imp___adjust_fdiv;
#endif  /* _M_IX86 */

            /*
             * Run the RTC initialization code for this DLL
             */
#ifdef _RTC
            _RTC_Initialize();
#endif  /* _RTC */

            /*
             * Call _setargv(), which will trigger a call to __setargv() if
             * SETARGV.OBJ is linked with the EXE.  If SETARGV.OBJ is not
             * linked with the EXE, a dummy _setargv() will be called.
             */
#ifdef WPRFLAG
            _wsetargv();
#else  /* WPRFLAG */
            _setargv();
#endif  /* WPRFLAG */

            /*
             * If the user has supplied a _matherr routine then set
             * __pusermatherr to point to it.
             */
            if ( !__defaultmatherr )
                __setusermatherr(_matherr);

#ifdef _M_IX86
            _setdefaultprecision();
#endif  /* _M_IX86 */

            /*
             * Do runtime startup initializers.
             *
             * Note: the only possible entry we'll be executing here is for
             * __lconv_init, pulled in from charmax.obj only if the EXE was
             * compiled with -J.  All other .CRT$XI* initializers are only
             * run as part of the CRT itself, and so for the CRT DLL model
             * are not found in the EXE.  For that reason, we call _initterm,
             * not _initterm_e, because __lconv_init will never return failure,
             * and _initterm_e is not exported from the CRT DLL.
             *
             * Note further that, when using the CRT DLL, executing the
             * .CRT$XI* initializers is only done for an EXE, not for a DLL
             * using the CRT DLL.  That is to make sure the -J setting for
             * the EXE is not overriden by that of any DLL.
             */
            _initterm( __xi_a, __xi_z );

#ifdef _RTC
            atexit(_RTC_Terminate);
#endif  /* _RTC */

            /*
             * Get the arguments for the call to main. Note this must be
             * done explicitly, rather than as part of the dll's
             * initialization, to implement optional expansion of wild
             * card chars in filename args
             */

#ifdef WPRFLAG
            startinfo.newmode = _newmode;

            argret = __wgetmainargs(&argc, &argv, &envp,
                                    _dowildcard, &startinfo);
#else  /* WPRFLAG */
            startinfo.newmode = _newmode;

            argret = __getmainargs(&argc, &argv, &envp,
                                   _dowildcard, &startinfo);
#endif  /* WPRFLAG */
            if (argret < 0)
                _amsg_exit(_RT_SPACEARG);


            /*
             * do C++ constructors (initializers) specific to this EXE
             */
            _initterm( __xc_a, __xc_z );

#ifdef _WINMAIN_
            /*
             * Skip past program name (first token in command line).
             * Check for and handle quoted program name.
             */
#ifdef WPRFLAG
            /* OS may not support "W" flavors */
            if (_wcmdln == NULL)
                return 255;
            lpszCommandLine = (wchar_t *)_wcmdln;
#else  /* WPRFLAG */
            lpszCommandLine = (unsigned char *)_acmdln;
#endif  /* WPRFLAG */

            while (*lpszCommandLine > SPACECHAR ||
                   (*lpszCommandLine&&inDoubleQuote)) {
                /*
                 * Flip the count from 1 to 0 or 0 to 1 if current character
                 * is DOUBLEQUOTE
                 */
                if (*lpszCommandLine==DQUOTECHAR) inDoubleQuote=!inDoubleQuote;
#ifdef _MBCS
                if (_ismbblead(*lpszCommandLine)) {
                    if (lpszCommandLine) {
                        lpszCommandLine++;
                    }
                }
#endif  /* _MBCS */
                ++lpszCommandLine;
            }

            /*
             * Skip past any white space preceeding the second token.
             */
            while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR)) {
                lpszCommandLine++;
            }

            StartupInfo.dwFlags = 0;
            GetStartupInfo( &StartupInfo );

#ifdef WPRFLAG
            mainret = wWinMain(
#else  /* WPRFLAG */
            mainret = WinMain(
#endif  /* WPRFLAG */
                       GetModuleHandleA(NULL),
                       NULL,
                       lpszCommandLine,
                       StartupInfo.dwFlags & STARTF_USESHOWWINDOW
                        ? StartupInfo.wShowWindow
                        : SW_SHOWDEFAULT
                      );
#else  /* _WINMAIN_ */

#ifdef WPRFLAG
            __winitenv = envp;
            mainret = wmain(argc, argv, envp);
#else  /* WPRFLAG */
            __initenv = envp;
            mainret = main(argc, argv, envp);
#endif  /* WPRFLAG */

#endif  /* _WINMAIN_ */

            if ( !managedapp )
                exit(mainret);

            _cexit();

        }
        __except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
        {
            /*
             * Should never reach here
             */

            mainret = GetExceptionCode();

            if ( !managedapp )
                _exit(mainret);

            _c_exit();

        } /* end of try - except */

        return mainret;
}

68

主题

710

帖子

719

积分

高级会员

Rank: 4

积分
719
QQ
发表于 2004-9-10 08:26:00 | 显示全部楼层

Re:请问 关于WIN32程序的问题?

william9527
的回答就可以解决你的 问题了

4

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
 楼主| 发表于 2004-9-10 09:57:00 | 显示全部楼层

Re:请问 关于WIN32程序的问题?

THANK YOU  !

0

主题

10

帖子

14

积分

新手上路

Rank: 1

积分
14
发表于 2004-9-12 17:54:00 | 显示全部楼层

Re:请问 关于WIN32程序的问题?

主要是运行界面的不同。win32 console application叫做CUI(console user interface),win32 application叫做GUI(graphics user interface),在windows核心编程一书里面有解释。

26

主题

324

帖子

325

积分

中级会员

Rank: 3Rank: 3

积分
325
QQ
发表于 2004-9-12 20:13:00 | 显示全部楼层

Re: Re:请问 关于WIN32程序的问题?

likedust: Re:请问 关于WIN32程序的问题?

主要是运行界面的不同。win32 console application叫做CUI(console user interface),win32 application叫做...

很好!赞

4

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
 楼主| 发表于 2004-9-14 21:49:00 | 显示全部楼层

Re:请问 关于WIN32程序的问题?

再次多谢各位!!!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-18 16:03

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表