You have three possibilities:
1. you can use the native CreateThread_() API command, which gives use also the real id
2. on Vista and higher, you can use the GetThreadId() API.
3. you can use these undocumented NT API calls on Windows 2000/XP/Vista/7:
Code: Select all
Structure CLIENT_ID
UniqueProcess.i;
UniqueThread.i;
EndStructure
Structure THREAD_BASIC_INFORMATION
ExitStatus.l;
TebBaseAddress.i;
ClientId.CLIENT_ID;
AffinityMask.l;
Priority.l;
BasePriority.l;
EndStructure
Enumeration
#ThreadBasicInformation
#ThreadTimes
#ThreadPriority
#ThreadBasePriority
#ThreadAffinityMask
#ThreadImpersonationToken
#ThreadDescriptorTableEntry
#ThreadEnableAlignmentFaultFixup
#ThreadEventPair
#ThreadQuerySetWin32StartAddress
#ThreadZeroTlsCell
#ThreadPerformanceCount
#ThreadAmILastThread
#ThreadIdealProcessor
#ThreadPriorityBoost
#ThreadSetTlsArrayAddress
#ThreadIsIoPending
#ThreadHideFromDebugger
#ThreadBreakOnTermination
#ThreadSwitchLegacyState
#ThreadIsTerminated
#ThreadLastSystemCall
#ThreadIoPriority
#ThreadCycleTime
#ThreadPagePriority
#ThreadActualBasePriority
#ThreadTebInformation
#ThreadCSwitchMon
EndEnumeration
Procedure GetThreadIDFromHandle(Handle.i)
Protected Info.THREAD_BASIC_INFORMATION
If NtQueryInformationThread_(Handle, #ThreadBasicInformation, @Info, SizeOf(Info),0) = 0
ProcedureReturn Info\ClientId\UniqueThread
EndIf
EndProcedure
Code: Select all
Procedure Test(a.i)
Debug GetCurrentThreadId_()
Repeat
Delay(10)
ForEver
EndProcedure
HThread = CreateThread(@Test(),0)
Debug GetThreadIDFromHandle(ThreadID(HThread))