CreateToolhelp32Snapshot() error RRS feed

  • Question


    I am making following call in a function GetProcesses() which will return me list of all running processes in the device.




    IntPtr handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);





    This function gets executed two times in my application. First time when application is loading and second time when application is closing (to close another associated process before exiting itself).

    First time value of  variable handle is valid while on second call its value is -1.....and hence Unable to create snapshot exception.

    This is happening on WM6. There is no problem on WM5....


    What needs to be done to make it run on WM6.








    Tuesday, July 29, 2008 1:44 PM


All replies

  • Hi

    here C#  source written  by me in my blog. there i had work with this snapshot functions.


    Thank you

    Tuesday, July 29, 2008 3:21 PM

    Thanks for the Reply RRave.


    The blog contains info for ThreadSnapshot only..... I get the error when i am trying to get the snapshot of all the running processes in WM6 (Asus p750 device).


    Can there be some device memory problem ? Guys pls give your suggestions ...I m stuck!





    Friday, August 1, 2008 5:27 AM
  • What's the value of System.Runtime.InteropServices.Marshal.GetLastWin32Error()? You can look up the error message here:



    Friday, August 1, 2008 7:49 AM
  • I have the same problem on Windows Mobile 5.0, this funciton returns -1


    IntPtr handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    the value of System.Runtime.InteropServices.Marshal.GetLastWin32Error() is 0 (Cero)

    I'll apreciate any help.


    Friday, January 29, 2010 6:26 PM