// Notify_Icon.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <shellapi.h>int g_count=5;
VOID CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
//这里根本没被调用过。为什么?
OutputDebugString("done\n");
if(!(--g_count))PostQuitMessage(0);;
return ;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int MyTimer= SetTimer(NULL,1,100,TimerProc);//返回值表示成功
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)){
}
KillTimer(NULL,MyTimer);
return 0;
}
//
#include "stdafx.h"
#include <shellapi.h>int g_count=5;
VOID CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
//这里根本没被调用过。为什么?
OutputDebugString("done\n");
if(!(--g_count))PostQuitMessage(0);;
return ;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int MyTimer= SetTimer(NULL,1,100,TimerProc);//返回值表示成功
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)){
}
KillTimer(NULL,MyTimer);
return 0;
}
这个是完全版本的程序
用了 precomplier 的。
编译没问题,问题是出在调用不生效。
你的定时处理函数怎么会被调用啊在while (GetMessage(&msg, NULL, 0, 0)){
}
中加上TranslateMessage(&msg);
DispatchMessage(&msg);
就可以了