您需要使用您在创建线程返回线程句柄。请参阅文档CreateThread
; SuspendThread
;和ResumeThread
。
特别是,从文档CreateThread
:
如果函数成功,返回值是一个句柄到新的线程。如果函数失败,返回值为NULL。
实施例:
HANDLE thread_handle = CreateThread(/*args*/); // hold on to this value (and check for failure)
if (thread_handle == NULL)
{
// handle creation error
}
DWORD suspend_retval = SuspendThread(thread_handle);
if (suspend_retval == static_cast<DWORD>(-1))
{
// handle suspend error
}
Scr_AddInt(1); // original work
DWORD resume_retval = ResumeThread(thread_handle);
if (resume_retval == static_cast<DWORD>(-1))
{
// handle resume error
}
这可能是值得的创建封装线程创建,暂停,恢复,和终止的包装类。该类可以在内部执行所有错误检查,并在适当时引发异常。
线程**不是**某些内存地址。寻找线程ID和进程ID。 – Deduplicator
我发出的threadid是0x8354F7A8,但我没有看到processid http://gyazo.com/13a976b7993ce574ff9489d82110f1cc – HorseFrog
这看起来太大了一个线程ID ... – Deduplicator