|
Prev: why CRT has to written in C
Next: Data Type
From: worlman385 on 8 Apr 2008 21:18 The prototype of GetExitCodeThread is like this - GetExitCodeThread( __in HANDLE hThread, __out LPDWORD lpExitCode ); ============================= why we put &dwExitCod in the parameter? like - DWORD dwExitCode; GetExitCodeThread( hth2, &dwExitCode ); ============================= digging further i found - typedef DWORD near *PDWORD; typedef DWORD far *LPDWORD; ============================= So DWORD* "equals" LPDWORD ??? then above LPDWORD lpExitCode should be taking parameter of DWORD* lpExitCode (Given DWORD* "equals" LPDWORD) ??? ============================= that's why &dwExitCode ? since &dwExitCode "returns" a pointer to DWORD.
From: Vincent Fatica on 8 Apr 2008 21:54 On Tue, 08 Apr 2008 18:18:27 -0700, worlman385(a)yahoo.com wrote: >that's why &dwExitCode ? since &dwExitCode "returns" a pointer to >DWORD. Not exactly; **you** supplied the pointer to the DWORD and GECT() puts information at that address. Think of it this way. There must first be a DWORD (a place to store the information). DWORD dwExitCode; You tell GetExitCodeThread() **where** that DWORD is. GetExitCodeThread( hth2, &dwExitCode ); GetExitCodeThread(), if successful, assigns the thread exit code to the DWORD at the location you specified. There's no reason to do so, but you could: DWORD dwExitCode; DWORD *foo = &dwExitCode; /* or LPDWORD foo = &dwExitCode; */ GetExitCodeThread( hth2, foo ); -- - Vince
From: worlman385 on 9 Apr 2008 02:40 but i found - typedef DWORD near *PDWORD; typedef DWORD far *LPDWORD; DWORD* is equal to LPDWORD why microsoft need make more confusion and create another type LPDWORD?? can people just use DWORD* then? > >There's no reason to do so, but you could: > > DWORD dwExitCode; > DWORD *foo = &dwExitCode; > /* or LPDWORD foo = &dwExitCode; */ > GetExitCodeThread( hth2, foo );
From: Alex Blekhman on 9 Apr 2008 04:52 <worlman385(a)yahoo.com> wrote: > but > > i found - > typedef DWORD near *PDWORD; > typedef DWORD far *LPDWORD; > > DWORD* is equal to LPDWORD > > why microsoft need make more confusion and create another type > LPDWORD?? > > can people just use DWORD* then? Because it's the relic of ancient 16-bit programming where pointers weren't just pointers. There were "far" and "near" pointers. Developers had to be careful to use appropriate pointers. So, Platform SDK made definitions for pointers in order to ease this tedious work. Today, new PSDK types and functions usually omit the "L" in their names and parameters (for example, look for `LITEM' structure in MSDN). Alex
From: Ben Voigt [C++ MVP] on 10 Apr 2008 18:16 > that's why &dwExitCode ? since &dwExitCode "returns" a pointer to > DWORD. (&dwExitCode) "evaluates" to a pointer to a DWORD. There's no "return" involved because there is no function call. I think that's why Vincent said you were wrong, he was thinking about the actual "return" inside GetExitCodeThread.
|
Pages: 1 Prev: why CRT has to written in C Next: Data Type |