|
From: Wanting2Learn on 22 Jan 2008 20:57 I am trying to get the ID of threads running in my program for debug purposes. Is the following code correct: DWORD dwID = GetCurrentThreadId(); CString sTemp; sTemp.Format(_T("%d"),dwID); TRACE(_T("%s Thread WHILE OK **\n"),sTemp); I am getting thread IDs for example: -1564372882 This number does not seem correct. Is this right, if not, how should it be done? Thanks Harry
From: Scott Seligman on 22 Jan 2008 21:18 <Wanting2Learn(a)discussions.microsoft.com> wrote: > >I am trying to get the ID of threads running in my program for debug >purposes. Is the following code correct: > >DWORD dwID = GetCurrentThreadId(); >CString sTemp; >sTemp.Format(_T("%d"),dwID); >TRACE(_T("%s Thread WHILE OK **\n"),sTemp); Well, you probably want to use a signed type, like 0x%08x instead of %d since DWORD is unsigned. >I am getting thread IDs for example: >-1564372882 > >This number does not seem correct. Why not? -- --------- Scott Seligman <scott at <firstname> and michelle dot net> --------- For of all sad words of tongue or pen, the saddest are these: 'It might have been.' -- John Greenleaf Whittier
From: " ctacke/>" on 22 Jan 2008 21:19 1. Why does it look bad to you? 2. You can use the Toolhelp API to get all thread IDs 3. You can use Remote Process Viewer to verify the IDs you get programmatically. -- Chris Tacke, eMVP Join the Embedded Developer Community http://community.opennetcf.com "Wanting2Learn" <Wanting2Learn(a)discussions.microsoft.com> wrote in message news:8C09B583-6190-45EB-90D1-5453751DEDCD(a)microsoft.com... >I am trying to get the ID of threads running in my program for debug > purposes. Is the following code correct: > > DWORD dwID = GetCurrentThreadId(); > CString sTemp; > sTemp.Format(_T("%d"),dwID); > TRACE(_T("%s Thread WHILE OK **\n"),sTemp); > > I am getting thread IDs for example: > -1564372882 > > This number does not seem correct. > > Is this right, if not, how should it be done? > > > Thanks > > Harry >
From: Anonymous on 24 Jan 2008 10:04 On Jan 23, 3:57 am, Wanting2Learn <Wanting2Le...(a)discussions.microsoft.com> wrote: > I am trying to get the ID of threads running in my program for debug > purposes. Is the following code correct: > > DWORD dwID = GetCurrentThreadId(); > CString sTemp; > sTemp.Format(_T("%d"),dwID); > TRACE(_T("%s Thread WHILE OK **\n"),sTemp); > > I am getting thread IDs for example: > -1564372882 > > This number does not seem correct. > > Is this right, if not, how should it be done? > > Thanks > > Harry It's an absolutely valid value for thread id. DWORD is unsigned value, but you're using %d specifier in format string, which stands for signed values - this why your value is interpreted as signed and you see the negative number in your output. I'd recommend you to use hex values, when printing id's and similar stuff. Use %x format specifier for this: sTemp.Format(_T("%x"),dwID); BR Denis
|
Pages: 1 Prev: Can't get RDA working get Next: Upnp .net control point problem |