
Linux下获取当前线程ID号函数:
pthread_t pthread_self();
返回:当前线程的ID号
pthread_t 数据类型的定义如下:
typedef unsigned long int pthread_t;
sizeof(pthread_t) = 4,4个字节的整数。
Windows下获取当前线程ID号的函数:
DWORD GetCurrentThreadId();
返回值:当前线程的ID号
DWORD数据类型定义:
typedef unsigned long DWORD;
在Windows下pthread-win库的pthread_t定义如下:
typedef struct {
void p; /Pointer to actual object /
unsigned int x; /Extra information - reuse count etc /
} ptw32_handle_t;
typedef ptw32_handle_t pthread_t;
与Linux的thread_t不一样,它是一个结构,不是一个整数值
在Windows和Linux下可用的获取线程ID号的内联函数如下:
#ifdef WIN32
#include <windowsh>
#else
#include <pthreadh>
#endif
inline unsigned int PthreadSelf()
{
#ifdef WIN32
return::GetCurrentThreadId();
#else
returnthread_self();
#endif
}
(以下都是windows下线程的相关函数)
得到当前线程句柄: GetCurrentThread(void)
得到当前线程ID: GetCurrentThreadId(void)
根据句柄得到线程ID: GetThreadId
根据窗口句柄得到此窗口所在线程的ID(同时得到进程的ID): GetWindowThreadProcessId
根据ID得到线程句柄: OpenThread(unsigned long)
挂起用SuspendThread
唤醒用ResumeThread
(强制)结束TerminateThread
线程是进程内部的一个执行单元,一个进程可以有多个线程,但是这些线程仅存在于该进程中,纯种是在它所属的进程地址空间里执行的,并在进程的地址空间对数据进行 *** 作。
输入下面的语句:
Requirements
Client
Requires Windows Vista
Server
Requires Windows Server 2008 or Windows Server 2003
Header
Declared in Winbaseh; include Windowsh
Library
Use Kernel32lib
DLL
Requires Kernel32dll
“取窗体句柄”时传递了过多的参数
说明你的那句 窗口句柄 = 取窗体句柄 (“GameGuardsed”, “D3D Window”, “FLYFF”)
写的参数多了,说白了就是一个逗号是一个参数。
不知道你那个“取窗体句柄”是什么子程序。
如果LZ那源码是复制的,引用了模块,那看看模块有没有用错吧,或者用其他方法取那个窗口的句柄。比如 取进程句柄 这样的
额好吧。。我看到了
子程序 取窗体句柄
你这个子程序是空的,那就是根本没有参数可填,也根本是个空壳子程序。。。没用的。。。
还是先编完这个子程序吧==
以上就是关于如何在Windows和Linux下获取当前线程的ID号全部的内容,包括:如何在Windows和Linux下获取当前线程的ID号、如何获取一个线程下的产生的窗体句柄、如何从线程ID获取线程名称等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)