OpenThread的调用

在VC6.0中使用HANDLE OpenThread(DWORD dwDesiredAccessBOOL bInheritHandleDWORD dwThreadId  );

时不能直接调用 因为其虽然在存在于kernel32.dll

 

在MSDN中声明

Requirements

  Windows NT/2000/XP: Included in Windows 2000 and later.
  Windows 95/98/Me: Included in Windows Me.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.

 

但是在VC98目录下的Winbase.h中并没有该函数的声明 所以再调用该函数时需要如下操作

//-->定义OpenThread函数类型 别忘了WINAPI(API都是_stdcall类型) typedef HANDLE (WINAPI * OPENTHREADFUN)(DWORD dwDesiredAccess,BOOL bInheritHandle,DWORD dwThreadId); //1:kernel32 大部分程序都自动加载了kernel32.dll 所以再获得句柄之前不需要Loadlibray HMODULE hKernel32 = ::GetModuleHandle(_T("kernel32.dll")); //2获得函数指针 OPENTHREADFUN pFun = (OPENTHREADFUN)GetProcAddress(hKernel32,_T("OpenThread")); //3调用 pFun(THREAD_ALL_ACCESS,FALSE,dwThreadId);

你可能感兴趣的:(Windows编程,Windows编程)