title: Open Folder Path if not already open, if open show window
body: <p>This seems like a simple task but I cannot seem to produce the results looking for.</p>
  
  <p>currently I have this code </p>
  
  <pre><code> Dim folderpath As String
  
  Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
      folderpath = "C:\epds\WIP"
      Process.Start("explorer.exe", folderpath)
  
  End Sub
  </code></pre>
  
  <p>That's fine and it opens my folder path as indicated, however, if the instance of that folder is already open in the explorer how do I just make that window current instead of opening a new window explorer?</p>
  
  <p>EDIT: This seemed to do the trick, thanks for pointing me in the right direction @Okuma.Scott</p>
  
  <pre><code>&lt;DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)&gt; _
  Private Shared Function FindWindow( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As IntPtr
  End Function
  
  &lt;DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)&gt; _
  Private Shared Function FindWindowByClass( _
    ByVal lpClassName As String, _
    ByVal zero As IntPtr) As IntPtr
  End Function
  
  &lt;DllImport("user32.dll", EntryPoint:="FindWindow", SetLastError:=True, CharSet:=CharSet.Auto)&gt; _
  Private Shared Function FindWindowByCaption( _
    ByVal zero As IntPtr, _
    ByVal lpWindowName As String) As IntPtr
  End Function
  
  Dim folderpath As String
  
  Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
      folderpath = "C:\epds\WIP"
      'Process.Start("explorer.exe", folderpath)
      Dim nWnd As IntPtr
      Dim ceroIntPtr As New IntPtr(0)
      Dim Wnd_name As String
  
      Wnd_name = "WIP"
      nWnd = FindWindow(Nothing, Wnd_name)
      'show the info
      If nWnd.Equals(ceroIntPtr) Then
          Process.Start("explorer.exe", folderpath)
      Else
          AppActivate(Wnd_name)
          SendKeys.SendWait("~")
      End If
  
  
  End Sub
  </code></pre>