选数程序

来源:互联网 发布:顶级域名的含义 编辑:程序博客网 时间:2024/05/22 12:52

选数程序- -

                                      

/*****************************************************************************
* FileName     : count.c
* Date            : 2005/05/11
* Author         : 蜀山木马
* Module        : 
* Description  : 
*
*   Copyright (c) 2005  All Rights Reserved.
*-----------------------------------------------------------------------------
*      Edit History
* NO Date            Modifier    Modified Content
* 1    2005/05/11 蜀山木马    Basic definition 
* 2    2005/05/17 蜀山木马                                
*****************************************************************************/
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>

#define MSG_STOP WM_USER+1

DWORD WINAPI CircleCount(LPVOID);

DWORD nCircleCountID;
HANDLE hCircleCount;

/****************************************************************************
* Function Name            : main
* Description                  : Functiong entry
* Input Parameters        : None
* Output Parameters     : None 
* Return Value               : None
* Caller                           : 
* Date                            : 2005/05/11
* Author                         : 蜀山木马
*****************************************************************************/
int main()
{
 printf("Press 'b'  to run...");
 while( _getch() != 'b'  );
 hCircleCount = CreateThread(NULL,0,CircleCount,NULL,0,&nCircleCountID);
 
 _getch();
 PostThreadMessage(nCircleCountID,MSG_STOP,0,0);

 CloseHandle(hCircleCount);

 return EXIT_SUCCESS;
}

/****************************************************************************
* Function Name            : CircleCount
* Description                  : Functiong entry
* Input Parameters        : LPVOID n
* Output Parameters     : NONE 
* Return Value               : DWORD
* Caller                           : 
* Date                            : 2005/05/11
* Author                         : 蜀山木马
*****************************************************************************/
DWORD WINAPI CircleCount(LPVOID n)
{
 MSG msg;
 int i = 0;
 BOOL flag = TRUE;
  
 while( flag )
 {
  if(PeekMessage( &msg,NULL,0,0,PM_REMOVE))
  {
   flag = FALSE;
  }
  else
  {
   printf("%d/n",i++);
   if(i == 500 )
    i = 0;
  }
 }
 
 printf("You select number is %d/n",i);

 return 0;

}

以上程序在VC++6.0下编译通过