小弟请大家帮帮忙,谢了. 你选择使用MFC 连接库 试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 请加入头文件<process.h>同时放一个MSDN的例子供你参考:基于CONSOLE的。Example/* BEGTHRD.C illustrates multiple threads using functions: * * _beginthread _endthread * * * This program requires the multithreaded library. For example, * compile with the following command line: * CL /MT /D "_X86_" BEGTHRD.C * * If you are using the Visual C++ development environment, select the * Multi-Threaded runtime library in the compiler Project Settings * dialog box. * */#include <windows.h>#include <process.h> /* _beginthread, _endthread */#include <stddef.h>#include <stdlib.h>#include <conio.h>void Bounce( void *ch );void CheckKey( void *dummy );/* GetRandom returns a random integer between min and max. */#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))BOOL repeat = TRUE; /* Global repeat flag and video variable */HANDLE hStdOut; /* Handle for console window */CONSOLE_SCREEN_BUFFER_INFO csbi; /* Console information structure */void main(){ CHAR ch = 'A'; hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); /* Get display screen's text row and column information. */ GetConsoleScreenBufferInfo( hStdOut, &csbi ); /* Launch CheckKey thread to check for terminating keystroke. */ _beginthread( CheckKey, 0, NULL ); /* Loop until CheckKey terminates program. */ while( repeat ) { /* On first loops, launch character threads. */ _beginthread( Bounce, 0, (void *) (ch++) ); /* Wait one second between loops. */ Sleep( 1000L ); }}/* CheckKey - Thread to wait for a keystroke, then clear repeat flag. */void CheckKey( void *dummy ){ _getch(); repeat = 0; /* _endthread implied */}/* Bounce - Thread to create and and control a colored letter that moves * around on the screen. * * Params: ch - the letter to be moved */void Bounce( void *ch ){ /* Generate letter and color attribute from thread argument. */ char blankcell = 0x20; char blockcell = (char) ch; BOOL first = TRUE; COORD oldcoord, newcoord; DWORD result; /* Seed random number generator and get initial location. */ srand( _threadid ); newcoord.X = GetRandom( 0, csbi.dwSize.X - 1 ); newcoord.Y = GetRandom( 0, csbi.dwSize.Y - 1 ); while( repeat ) { /* Pause between loops. */ Sleep( 100L ); /* Blank out our old position on the screen, and draw new letter. */ if( first ) first = FALSE; else WriteConsoleOutputCharacter( hStdOut, &blankcell, 1, oldcoord, &result ); WriteConsoleOutputCharacter( hStdOut, &blockcell, 1, newcoord, &result ); /* Increment the coordinate for next placement of the block. */ oldcoord.X = newcoord.X; oldcoord.Y = newcoord.Y; newcoord.X += GetRandom( -1, 1 ); newcoord.Y += GetRandom( -1, 1 ); /* Correct placement (and beep) if about to go off the screen. */ if( newcoord.X < 0 ) newcoord.X = 1; else if( newcoord.X == csbi.dwSize.X ) newcoord.X = csbi.dwSize.X - 2; else if( newcoord.Y < 0 ) newcoord.Y = 1; else if( newcoord.Y == csbi.dwSize.Y ) newcoord.Y = csbi.dwSize.Y - 2; /* If not at a screen border, continue, otherwise beep. */ else continue; Beep( ((char) ch - 'A') * 100, 175 ); } /* _endthread given to terminate */ _endthread();} alt+f5 (alt+f7)then link set path ok 建议先看看书。不过可能看了书,上面的问题也提得不多。解决:1。project->settings->C/C++->选CateGory中得Code Generation->Use Runtime Lib->选择Debug MulitThread2。把CDialogDlg.cpp加到工程里:选Project->Add to Project->Files加进来。然后安装1步所说 求助啊 ,在MFC里加人下面的代码出现问题,求解!!!! 急,文件属性对话框出不来(代码运行正常) 花钱求 同花顺期货历史交易数据的读取 关于复制的实现 运行后出现控件测试容器,没有出现我的程序界面,怎么回事? pDC->TextOut(x,y,str)中的y值怎么越小越在下面输出? CreateProcess、CreatePipe问题 获得系统日期和时间的API函数 请问如何实现可以按下去的按钮 求助 截取窗口事件PreStansMessage和WindowProc有什么区别? 关于dll的小问题
同时放一个MSDN的例子供你参考:基于CONSOLE的。
Example/* BEGTHRD.C illustrates multiple threads using functions:
*
* _beginthread _endthread
*
*
* This program requires the multithreaded library. For example,
* compile with the following command line:
* CL /MT /D "_X86_" BEGTHRD.C
*
* If you are using the Visual C++ development environment, select the
* Multi-Threaded runtime library in the compiler Project Settings
* dialog box.
*
*/#include <windows.h>
#include <process.h> /* _beginthread, _endthread */
#include <stddef.h>
#include <stdlib.h>
#include <conio.h>void Bounce( void *ch );
void CheckKey( void *dummy );/* GetRandom returns a random integer between min and max. */
#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))BOOL repeat = TRUE; /* Global repeat flag and video variable */
HANDLE hStdOut; /* Handle for console window */
CONSOLE_SCREEN_BUFFER_INFO csbi; /* Console information structure */void main()
{
CHAR ch = 'A'; hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); /* Get display screen's text row and column information. */
GetConsoleScreenBufferInfo( hStdOut, &csbi ); /* Launch CheckKey thread to check for terminating keystroke. */
_beginthread( CheckKey, 0, NULL ); /* Loop until CheckKey terminates program. */
while( repeat )
{
/* On first loops, launch character threads. */
_beginthread( Bounce, 0, (void *) (ch++) ); /* Wait one second between loops. */
Sleep( 1000L );
}
}/* CheckKey - Thread to wait for a keystroke, then clear repeat flag. */
void CheckKey( void *dummy )
{
_getch();
repeat = 0; /* _endthread implied */}/* Bounce - Thread to create and and control a colored letter that moves
* around on the screen.
*
* Params: ch - the letter to be moved
*/
void Bounce( void *ch )
{
/* Generate letter and color attribute from thread argument. */
char blankcell = 0x20;
char blockcell = (char) ch;
BOOL first = TRUE;
COORD oldcoord, newcoord;
DWORD result;
/* Seed random number generator and get initial location. */
srand( _threadid );
newcoord.X = GetRandom( 0, csbi.dwSize.X - 1 );
newcoord.Y = GetRandom( 0, csbi.dwSize.Y - 1 );
while( repeat )
{
/* Pause between loops. */
Sleep( 100L ); /* Blank out our old position on the screen, and draw new letter. */
if( first )
first = FALSE;
else
WriteConsoleOutputCharacter( hStdOut, &blankcell, 1, oldcoord, &result );
WriteConsoleOutputCharacter( hStdOut, &blockcell, 1, newcoord, &result ); /* Increment the coordinate for next placement of the block. */
oldcoord.X = newcoord.X;
oldcoord.Y = newcoord.Y;
newcoord.X += GetRandom( -1, 1 );
newcoord.Y += GetRandom( -1, 1 ); /* Correct placement (and beep) if about to go off the screen. */
if( newcoord.X < 0 )
newcoord.X = 1;
else if( newcoord.X == csbi.dwSize.X )
newcoord.X = csbi.dwSize.X - 2;
else if( newcoord.Y < 0 )
newcoord.Y = 1;
else if( newcoord.Y == csbi.dwSize.Y )
newcoord.Y = csbi.dwSize.Y - 2; /* If not at a screen border, continue, otherwise beep. */
else
continue;
Beep( ((char) ch - 'A') * 100, 175 );
}
/* _endthread given to terminate */
_endthread();
}
then link set path
ok
解决:
1。project->settings->C/C++->选CateGory中得Code Generation->Use Runtime Lib->选择Debug MulitThread
2。把CDialogDlg.cpp加到工程里:选Project->Add to Project->Files加进来。然后安装1步所说