CreateToolhelp32Snapshot

This function takes a snapshot of the processes and the heaps, modules, and threads used by the processes.

HANDLE WINAPI CreateToolhelp32Snapshot( 
DWORD dwFlags, 
DWORD th32ProcessID );

Parameters

  • dwFlags
    Specifies portions of the system to include in the snapshot. This parameter can be one of the following:

    Value Description
    TH32CS_SNAPALL Equivalent to specifying TH32CS_SNAPHEAPLIST, TH32CS_SNAPMODULE, TH32CS_SNAPPROCESS, and TH32CS_SNAPTHREAD.
    TH32CS_SNAPHEAPLIST Includes the heap list of the specified process in the snapshot.
    TH32CS_SNAPMODULE Includes the module list of the specified process in the snapshot.
    TH32CS_SNAPPROCESS Includes the process list in the snapshot.
    TH32CS_SNAPTHREAD Includes the thread list in the snapshot.
  • th32ProcessID
    Process identifier. This parameter can be zero to indicate the current process. This parameter is used when the TH32CS_SNAPHEAPLIST or TH32CS_SNAPMODULE value is specified. Otherwise, it is ignored.

Return Valuess

An open handle to the specified snapshot indicates success. – 1 indicates failure.

Remarks

The snapshot returned is a copy of the current state of the system. To close a snapshot call the CloseToolhelp32Snapshot function. Do not call the CloseHandle function to close the snapshot call. Calling CloseHandle to close the snapshot call generates a memory leak.

The snapshot taken by this function is examined by the other tool help functions to provide their results. Access to the snapshot is read only. The snapshot handle acts like an object handle and is subject to the same rules regarding which processes and threads it is valid in.

To retrieve an extended error status code generated by this function, use the GetLastError function.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS        

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CloseHandle, CloseToolhelp32Snapshot, GetLastError

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.