CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2008
    Posts
    62

    Unhappy how to get parent process information

    Hi Friends,
    I want to delete all the files in the given directory, i did that.
    But while deleting some files it shows error like 'This file is used by another program'. So i want to kill the process which holding this file..


    I can get the parent ID if i know the child id or child name, but here I know only file name...If i get the parent process id i can kill that process and delete the file...

    Give me the idea to get the parent id by giving file name or deleting the busy file

    Please help me,

    Thanks,
    Riyas.B
    Growing Developer

  2. #2
    Join Date
    Jan 2008
    Posts
    178

    Re: how to get parent process information

    Jut enumerate the handles , get the pid and close remotely the handle

  3. #3
    Join Date
    Oct 2008
    Posts
    62

    Re: how to get parent process information

    How to enumerate handles?

    If i enumerate all the handles, how can i identify the handle of the parent process?, here i know only the child file name

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: how to get parent process information

    I can think of 2 options.
    The first option may be to use the MoveFileEx API with the MOVEFILE_DELAY_UNTIL_REBOOT Flag.

    Another option, is outlined in the article ( yes, right here on CodeGuru ) :
    http://www.codeguru.com/cpp/w-p/file...icle.php/c1287

    But, I never could actually see the whole logic in deleting a file which is "currently busy" - what if it's a system file ¿

  5. #5
    Join Date
    Aug 2009
    Posts
    2

    Re: how to get parent process information

    Just use ProcExp (http://technet.microsoft.com/en-us/s.../bb896653.aspx) instead. It finds out which process is holding up your files/dlls - handles in general.

  6. #6
    Join Date
    Dec 2008
    Posts
    114

    Re: how to get parent process information

    Quote Originally Posted by piyush_soni View Post
    Just use ProcExp
    No.
    By programming.
    You enumerate the handles and close the one you want from the matching PID

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured