QUEUSERAPC

来源:互联网 发布:linux tomcat7 log4j 编辑:程序博客网 时间:2024/06/02 02:29
include "stdafx.h"#include <Windows.h>#include <process.h>#include <stdio.h>#pragma  comment (lib,"Kernel32.lib")#pragma comment(lib,"user32")typedef unsigned (__stdcall  *threadfunc)(VOID *);typedef struct _IO_STATUS_BLOCK {  ULONG  Status;    ULONG  Information;} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;void WINAPI  APC_ROUTINES (ULONG_PTR dwParam);HANDLE hEvent;unsigned __stdcall ThreadStaticEntryPoint(void *param)  {  printf("Process_id=%d\n",GetCurrentProcessId());printf("Thread_id=%d\n",GetCurrentThreadId()); //_asm{int 3};QueueUserAPC((PAPCFUNC)APC_ROUTINES,GetCurrentThread(),NULL); SleepEx(1000,TRUE);//让切片,在APC执行或者TIMEOUT返回return 0;}void WINAPI  APC_ROUTINES (ULONG_PTR dwParam){//_asm{int 3};MessageBoxA(NULL,"ASSSS","ASDFAS",MB_OK);    return;}int main(int argc,char* argv[]){    int a=1000;HANDLE handle=(HANDLE)_beginthreadex(NULL,0,ThreadStaticEntryPoint,(PVOID)&a,0,0);    WaitForSingleObject(handle,INFINITE);CloseHandle(handle);return 0;}