Hello,
first of all sorry for the vague title - I'm just not quite sure what the exact problem is.
My programm is trying to dismount the thumb-drive from which it is being executed. To be able to do this, it first copies itself to the system's temp-folder (using CopyFile) and launches the new instance of itself (using ShellExecuteEx) from there before exiting. The new instance then tries to dismount the drive.
Since you're reading this you can imagine it didn't work . I'm guessing Windows still has some kind of reference to the original instance of my application, but I don't know what that would be since I'm not requesting a process handle from ShellExecuteEx (meaning I'm not using SEE_MASK_NOCLOSEPROCESS). I've tried launching the application manually directly from the temp folder and this works as intended (drive dismounts properly).
This is how ShellExecuteEx is being used in my application...
I've also verified that the original instance that was launched from the drive is no longer running after these lines of code.Code:[...] SHELLEXECUTEINFO sei; ZeroMemory(&sei, sizeof(sei)); sei.cbSize = sizeof(sei); sei.lpFile = filename; // was passed in as function parameter sei.lpParameters= param; // same sei.nShow = SW_SHOW; sei.fMask = SEE_MASK_FLAG_NO_UI; [...] sei.lpVerb = "open"; [...] if (!ShellExecuteEx(&sei)) return FALSE; [...]
Any hints, comments, ideas would really be appreciated. Thank you