アットウィキロゴ

WinMain

概要

windowsプログラムのエントリーポイント
ソースwin/winMain.c

引数

  • hInstance アプリケーションの現在のインスタンスのハンドルが入ります。
  • hPrevInstance アプリケーションの前のインスタンスのハンドルが入ります。Win32 アプリケーションでは、常に NULL です。
  • lpCmdLine アプリケーションのコマンドラインが格納された NULL で終わる文字列へのポインタが入ります。
  • nCmdShow ウィンドウの表示状態の指定が入ります。次のいずれかの値が渡されます。


戻り値

APIENTRYは、WINAPIと同じで、#define WINAPI __stdcall
通常では Tk_Main からは戻ってこない。何かが発生して、 Tk_Main から戻ってきたときは1を返す。

処理

 WishPanicをTclがPanicした時に呼ぶように設定
 Tcl_SetPanicProc(WishPanic);

 consoleRequiredをTRUEに設定
 consoleRequired = TRUE;

 全てのロケールをCに設定
 setlocale(LC_ALL, "C");

 argc = __argc;
 argv = __argv;

 バックスラッシュをスラッシュに変更
 for (p = argv[0]; *p != '\0'; p++) {
   if (*p == '\\') {
     *p = '/';
  }
 }


 Tk_Mainの呼び出し。TK_LOCAL_APPINITは、win/Tcl_AppInitにdefineされている。
 Tk_Main(argc, argv, TK_LOCAL_APPINIT);
 return 1;


ソース

 /*
  *----------------------------------------------------------------------
  *
  * WinMain --
  *
  *	Main entry point from Windows.
  *
  * Results:
  *	Returns false if initialization fails, otherwise it never returns.
  *
  * Side effects:
  *	Just about anything, since from here we call arbitrary Tcl code.
  *
  *----------------------------------------------------------------------
  */
 
 int APIENTRY
 WinMain(
     HINSTANCE hInstance,
     HINSTANCE hPrevInstance,
     LPSTR lpszCmdLine,
     int nCmdShow)
 {
     char **argv;
     int argc;
     char *p;
 
     Tcl_SetPanicProc(WishPanic);
 
     /*
      * Create the console channels and install them as the standard channels.
      * All I/O will be discarded until Tk_CreateConsoleWindow is called to
      * attach the console to a text widget.
      */
 
     consoleRequired = TRUE;
 
     /*
      * Set up the default locale to be standard "C" locale so parsing is
      * performed correctly.
      */
 
     setlocale(LC_ALL, "C");
 
     /*
      * Get our args from the c-runtime. Ignore lpszCmdLine.
      */
 
 #if defined(__CYGWIN__)
     setargv(&argc, &argv);
 #else
     argc = __argc;
     argv = __argv;
 #endif
 
     /*
      * Forward slashes substituted for backslashes.
      */
 
     for (p = argv[0]; *p != '\0'; p++) {
 	if (*p == '\\') {
 	    *p = '/';
 	}
     }
 
 #ifdef TK_LOCAL_MAIN_HOOK
     TK_LOCAL_MAIN_HOOK(&argc, &argv);
 #endif
     
 
     Tk_Main(argc, argv, TK_LOCAL_APPINIT);
     return 1;
 }
最終更新:2011年10月31日 16:03