The cast works best if you don't imply another conversion to a temporary. Just return the value directly from the syscall/pthreads call, while casting to a DWORD.