4eyesgirl
asked on
Need a portable version of GetThreadId and GetProcessId to retrieve Process and Thread Id
Hi expert,
I need to retrieve the current Process and Thread Id information. GetThreadId and GetProcessId is for windows only? I need a system call that can portable to all platform. Does QT has functions to do that?
I am using QT3.3.3. Thanks!
I need to retrieve the current Process and Thread Id information. GetThreadId and GetProcessId is for windows only? I need a system call that can portable to all platform. Does QT has functions to do that?
I am using QT3.3.3. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Do you know if QT provides a portable version so I don't have to do the #ifdef
No, checked it and found nothing - neither QApplication nor QThread have any members regarding that issue. Anyway, it's just in a single place ;o)
ASKER
Would pthread_self() works?
Well, that gives you the 'pthread_t' for the current thread. So, if that is what you want: Yes.
ASKER
When I do the following, it prints out hex instead of dec
psthread_t pth_id = psthread_self();
std::cout << pth_id;
How to convert it to dec on all platforms?
psthread_t pth_id = psthread_self();
std::cout << pth_id;
How to convert it to dec on all platforms?
ASKER
can getpid() works on windows?
Open in new window