具体源程序如下(是一个画图型的程序,一个旋转的风车,但是我没有看见过它的运行界面?那位帮帮忙!非常感谢!):
#include "stdafx.h"
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define Pi 3.1415926long WINAPI WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int nNum=0,nMaxNum=20;
int WINAPI WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
MSG Message;
HWND hWnd;
WNDCLASS WndClass;
    WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hbrBackground = (HBRUSH)(GetStockObject(WHITE_BRUSH));
WndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = WndProc;
WndClass.lpszClassName = "icmean";
WndClass.lpszMenuName = NULL;
WndClass.style = 0; if (!RegisterClass(&WndClass))
{
MessageBeep(0);
return FALSE;
}
hWnd = CreateWindow("iceman",
"icmean",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
600,
450,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&Message,0,0,0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
long WINAPI WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
HDC hDC;
HBRUSH hBrush;
HPEN hPen;
PAINTSTRUCT PtStr;
    int nCentreX,nCentreY;
double fAngle; switch (iMessage)
{
case WM_PAINT:
 hDC = BeginPaint(hWnd,&PtStr);
 SetMapMode(hDC,MM_ANISOTROPIC);
 SetWindowExtEx(hDC,400,300,NULL);
 SetViewportExtEx(hDC,600,450,NULL);
             SetViewportOrgEx(hDC,300,200,NULL);
 
 hPen = (HPEN)GetStockObject(BLACK_PEN);
 SelectObject(hDC,hPen);
 Ellipse(hDC,-100,-100,100,100);  hBrush = CreateSolidBrush(RGB(255,0,0));
 SelectObject(hDC,hBrush);
 fAngle = 2*Pi/nMaxNum*nNum;
 nCentreX = (int)(50*cos(fAngle));
 nCentreY = (int)(50*sin(fAngle));
 Pie(hDC,nCentreX-50,nCentreY-50,
 nCentreX+50,nCentreY+50,
 (int)(nCentreX+50*cos(fAngle)),(int)(nCentreY+50*sin(fAngle)),
 (int)(nCentreX+50*cos(fAngle+Pi)),(int)(nCentreY+50*sin(fAngle+Pi)));
 hBrush = CreateSolidBrush(RGB(255,255,0));
 SelectObject(hDC,hBrush);
 nCentreX = (int)(50*cos(fAngle+2*Pi/3));
 nCentreY = (int)(50*sin(fAngle+2*Pi/3));
 Pie(hDC,nCentreX-50,nCentreY-50,
 nCentreX+50,nCentreY+50,
 (int)(nCentreX+50*cos(fAngle+2*Pi/3)),(int)(nCentreY+50*sin(fAngle+2*Pi/3)),
 (int)(nCentreX+50*cos(fAngle+Pi+2*Pi/3)),(int)(nCentreY+50*sin(fAngle+Pi+2*Pi/3)));

 
 hBrush = CreateSolidBrush(RGB(255,255,0));
 SelectObject(hDC,hBrush);
 nCentreX = (int)(50*cos(fAngle+4*Pi/3));
 nCentreY = (int)(50*sin(fAngle+4*Pi/3));
 Pie(hDC,nCentreX-50,nCentreY-50,
 nCentreX+50,nCentreY+50,
 (int)(nCentreX+50*cos(fAngle+4*Pi/3)),(int)(nCentreY+50*sin(fAngle+4*Pi/3)),
 (int)(nCentreX+50*cos(fAngle+Pi+4*Pi/3)),(int)(nCentreY+50*sin(fAngle+Pi+4*Pi/3)));

 nNum++;
 Sleep(100);
 InvalidateRect(hWnd,NULL,1);
 EndPaint(hWnd,&PtStr);
 return 0;
case WM_DESTROY:
 PostQuitMessage(0);
 return 0;
default:
 return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
}

解决方案 »

  1.   

    是不是将AA。EXE的属性设为了只读?
      

  2.   

    你說的沒有運行介面是指沒有窗口出來? 如果係那應該aa.exe不是完全不能生成, 而是只能生成一次, 但執行一次就不能了. 試試按CTRL+ALT+DEL來看看見不見aa.exe. 如果見到, 試把
    if (!hWnd)
    {
     MessageBox(NULL, "Can't create window!", NULL, 0);
     return 1;
    }
    加再CreateWindow之後, 再把
    ShowWindow(hWnd,nCmdShow);
    改成
    ShowWindow(hWnd,SW_SHOW);
    因為你現在不能確定nCmdShow的值
      

  3.   

    我刚才不知道改了什么地方,报的错误变成这样了:???WHY???
    fatal error C1010: unexpected end of file while looking for precompiled header directive
      

  4.   

    你可以这样试试,保存源程序,将debug目录下的所有文件删掉,再重新编译一下,也许会起作用。
      

  5.   

    我搞定了!谢谢大家!
    顺便问一句,stdafx.h这个头文件是干什么的?谢谢!
      

  6.   

    我也碰到过这样的问题,连按两下ctrl+f5,就ok了
      

  7.   

    stdafx.h这个头文件是干什么的?谢谢! 
      

  8.   

    stdafx.h 是 VC 预编译用的!