We mainly want to implement a function to determine whether the process is multi-threaded. Different content is displayed as needed.
I don't know yet...
Mark.
After studying it, I went to the snow forum and found the following information. There is an example.
Http://bbs.pediy.com/showthread.php? T = 98078
Then I finally wrote a simple example After pondering for a long time.
Http://bbs.pediy.com/showthread.php? P = 1098221 # post1098221
Http://baike.baidu.com/view/589425.htm here also can.
# Include <tlhelp32.h> Void Testprocessgetthreadnumber (){ Int I = 0 ; Char Buff [ 9 ]; Processentry32 pe32; pe32.dwsize = Sizeof (Pe32); handle hprocesssnap =: Createconlhelp32snapshot (th32cs_snapprocess, 0 ); If (Hprocesssnap = Invalid_handle_value) {printf ( " Createconlhelp32snapshot call failed. \ n " ); Return ;} Bool bmore =: Process32first (hprocesssnap ,& Pe32); handle hprocess; printf ( " %-30 S %-20 S %-20 S %-15s \ n " , " Szexefile " , " Th32processid " , " Th32parentprocessid " , " Cntthreads " ); While (Bmore) {printf ( " %-30 s " , Pe32.szexefile); printf ( " %-20d " , Pe32.th32processid); printf ( " %-20d " , Pe32.th32parentprocessid ); // Display the number of threads of a process Printf ( " %-15D \ n " , Pe32.cntthreads); bmore = Process32next (hprocesssnap ,& Pe32); I ++ ; // Pe32.th32moduleid } Printf ( " Process count: % d \ n " , I); System ( " Pause " ); Exit ( 0 );}
Another problem encountered today is that string. Data () is used to obtain an int integer using atoi (). The range is too small. You need to use functions such as atoll, but no.
One of the shlwapi. h libraries can use strtoint64a.
Defined:
Lwstdapi _ (bool) strtoint64exa (_ in lpcstr pszstring, _ in stif_flags dwflags, _ out Longlong * pllret );
Set the second parameter to 0. 1 is hexadecimal. The first is the target C string address. The third parameter is the address of the target long. The returned value is true or false to determine whether the operation is successful.