I've succesfully obtained the handle to the current File Explorer window using
'Get handle to active window
Dim hWnd As IntPtr = GetForegroundWindow()
I have not been succesful finding the object that contains the path the aforementioned window is displaying. This path is supposed to reside in the process of the window, obtained too by
Dim ProcessID As UInt32 = Nothing
Dim ptr As UInt32 = GetWindowThreadProcessId(hWnd, ProcessID)
Dim Proc As Process = Process.GetProcessById(ProcessID)
However Proc.MainModule.Filename will deliver the path to the process only when executed within the IDE (VS2013). It will suddenly stop when executed outside. Can anyone please explain to me what I am failing to understand? Thanks.