File:  [OS/2 SDKs] / os232sdk / toolkt20 / c / samples / semaph / sem_init.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:30 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1990, HEAD
Microsoft OS/2 SDK 2.0 05-30-1990

/*==============================================================*\
 *  sem_init.c - routines for initialization and exit processing	*
 *      Created 1990, Microsoft, IBM Corp.                      *
 *--------------------------------------------------------------*
 *								*
 *  This module contains the code for application initialization*
 *  as well as the code for exit list processing		*
 *								*
 *--------------------------------------------------------------*
 *								*
 *  This source file contains the following functions:		*
 *								*
 *	Init() - initialization routines			*
 *	ExitProc(usTermCode) - exit list processing procedure	*
 *								*
\*==============================================================*/

/*--------------------------------------------------------------*\
 *  Include files, macros, defined constants, and externs	*
\*--------------------------------------------------------------*/

#define  LINT_ARGS

#define  INCL_WIN
#define  INCL_DOSPROCESS
#include <os2.h>
#include <string.h>
#include "sem_main.h"
#include "sem_xtrn.h"
/*--------------------------------------------------------------*\
 *  Global variables						*
\*--------------------------------------------------------------*/

/*--------------------------------------------------------------*\
 *  Entry point declarations					*
\*--------------------------------------------------------------*/

/****************************************************************\
 *  Initialization routine					*
 *--------------------------------------------------------------*
 *								*
 *  Name:   Init()						*
 *								*
 *  Purpose: Performs initialization functions required 	*
 *		before the main window can be created.		*
 *								*
 *  Usage:  Called once before the main window is created.	*
 *								*
 *  Method:							*
 *	    - installs the routine ExitProc into the		*
 *		DosExitList chain				*
 *	    - registers all window classes			*
 *	    - performs any command line processing		*
 *								*
 *  Returns:							*
 *	    TRUE - initialization is successful 		*
 *	    FALSE - initialization failed			*
\****************************************************************/

BOOL Init(VOID)
{
    /* Add ExitProc to the exit list to handle the exit processing */
    if(DosExitList(EXLST_ADD, (PFNEXITLIST)ExitProc))  {
	    return FALSE;
    }

    /* load application name from resource file */
    if(!WinLoadString(hab, NULL, IDS_APPNAME, MAXAPPNAMELEN, szAppName))
	    return FALSE;
   
    /* register the main client window class */
    if(!WinRegisterClass(hab,
			(PSZ)szAppName,
			(PFNWP)MainWndProc,
			CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPCHILDREN,
			0))  {
	return FALSE;
    }

    /* initialize data structures */
    InitSemaphExample ();
    /*--------------------------------------------------*\
     *	    Add any command line processing here	*
    \*--------------------------------------------------*/


    return TRUE;

}  /* Init() */



/****************************************************************\
 *  Exit list processing procedure				*
 *--------------------------------------------------------------*
 *								*
 *  Name:   ExitProc(usTermCode)				*
 *								*
 *  Purpose: Cleans up certain resources when the application	*
 *		terminates					*
 *								*
 *  Usage:  Routine is called by DosExitList when the		*
 *	    application exits					*
 *								*
 *  Method: global resources, such as the main window and	*
 *	    message queue, are destroyed and any system 	*
 *	    resources used are freed				*
 *								*
 *  Returns:  Returns EXLST_EXIT to the DosExitList handler	*
 *								*
\****************************************************************/

VOID PASCAL FAR ExitProc(usTermCode)
USHORT usTermCode;	/* code for the reason for termination */
{

    WinDestroyWindow(hwndMainFrame);

    /*--------------------------------------------------*\
     *	    Any other system resources used		*
     *	    (e.g. memory or files) should be freed here *
    \*--------------------------------------------------*/

    WinDestroyMsgQueue(hmq);

    WinTerminate(hab);

    DosExitList(EXLST_EXIT, 0L);    /* termination complete */

    /* This routine currently doesn't use the usTermCode parameter so *\
     *	it is referenced here to prevent an 'Unreferenced Parameter'  *
    \*	warning at compile time 				      */

    usTermCode;

}   /* ExitProc() */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.