刘 刘麻子 Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-12 #3 在操作系统眼里 线程好象 并没有 主次 之分
S satanmonkey Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-13 #4 to :esuper2000<br>toolhelp32里哪里有?<br><br>to:刘麻子<br>我只是想知道那个线程创造的这个已知线程
E esuper2000 Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-13 #5 win98 win2k都支持toolhelp32,但winnt不支持
S satanmonkey Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-13 #6 我知道toolhelp32,我是问toolhelp32的那部分功能做到找到父线程?
E esuper2000 Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-13 #7 TProcessEntry32.th32ParentProcessID
S savetime Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-13 #8 线程归属于进程,好像没有公开的 API 能获得父线程。<br>另外,父线程可能先于子线程终止。
刘 刘麻子 Unregistered / Unconfirmed GUEST, unregistred user! 2004-06-13 #9 在Delphi有好多方法来创建了线程,但是本质上都是调用CreateThread这个API来创建的<br><br>在windows操作系统时候 Delphi 线程类创建过程如下:<br>constructor TThread.Create(CreateSuspended: Boolean);<br>begin<br> inherited Create;<br> AddThread;<br> FSuspended := CreateSuspended;<br> FCreateSuspended := CreateSuspended;<br> FHandle := BeginThread(nil, 0, @ThreadProc, Pointer(Self), CREATE_SUSPENDED, FThreadID);<br> if FHandle = 0 then<br> raise EThread.CreateResFmt(@SThreadCreateError, [SysErrorMessage(GetLastError)]);<br>end;<br><br>实际上是调用了 Delphi 中的函数 BeginThread来创建一个线程,<br>而BeginThread过程如下:<br>function BeginThread(SecurityAttributes: Pointer; StackSize: LongWord;<br> ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord;<br> var ThreadId: LongWord): Integer;<br>var<br> P: PThreadRec;<br>begin<br> New(P);<br> P.Func := ThreadFunc;<br> P.Parameter := Parameter;<br> IsMultiThread := TRUE;<br> Result := CreateThread(SecurityAttributes, StackSize, @ThreadWrapper, P,<br> CreationFlags, ThreadID);<br>end;<br><br>最终都是调用了 CreateThread。。。 []<br>
在Delphi有好多方法来创建了线程,但是本质上都是调用CreateThread这个API来创建的<br><br>在windows操作系统时候 Delphi 线程类创建过程如下:<br>constructor TThread.Create(CreateSuspended: Boolean);<br>begin<br> inherited Create;<br> AddThread;<br> FSuspended := CreateSuspended;<br> FCreateSuspended := CreateSuspended;<br> FHandle := BeginThread(nil, 0, @ThreadProc, Pointer(Self), CREATE_SUSPENDED, FThreadID);<br> if FHandle = 0 then<br> raise EThread.CreateResFmt(@SThreadCreateError, [SysErrorMessage(GetLastError)]);<br>end;<br><br>实际上是调用了 Delphi 中的函数 BeginThread来创建一个线程,<br>而BeginThread过程如下:<br>function BeginThread(SecurityAttributes: Pointer; StackSize: LongWord;<br> ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord;<br> var ThreadId: LongWord): Integer;<br>var<br> P: PThreadRec;<br>begin<br> New(P);<br> P.Func := ThreadFunc;<br> P.Parameter := Parameter;<br> IsMultiThread := TRUE;<br> Result := CreateThread(SecurityAttributes, StackSize, @ThreadWrapper, P,<br> CreationFlags, ThreadID);<br>end;<br><br>最终都是调用了 CreateThread。。。 []<br>