I make it using VS 2010, in 2008 I think same. lets make new Visual Studio Project, Windows Form Application. and import this reference "" look this:
press "OK", and the begining of the code (before class) import this:
and then copy this code to your project:
The code will generate a timer and listbox in the form, so you don't have to adding control in the form. you can modify the code to running like a "On Access Scanner Program", have a nice program :-)
To test the program, Open two or more explorer, and then start the program.. and see what you get.
if you need to download the project, CLICK HERE TO DOWNLOAD
Add references "Microsoft Shell Controls and Automation" |
Imports Shell32
and then copy this code to your project:
Public Class Form1
Dim Lb As New ListBox
Dim WithEvents RoutineTimer As New Timer
Private Sub Form1_Load() Handles MyBase.Load
Lb.Parent = Me
Lb.Dock = DockStyle.Fill
Me.Text = "Opened Folder by user (explorer)"
RoutineTimer.Interval = 1000
RoutineTimer.Start()
End Sub
Sub GetOpenedFolder()
Dim MShell As New Shell
Dim SFV As ShellFolderView
Lb.Items.Clear()
On Error Resume Next
For Each o In MShell.Windows
If TypeName(o.document) <> "HTMLDocument" Then
SFV = o.document
If SFV.Folder.Items.Count > 0 Then
Lb.Items.Add(TrimPath(CType(SFV.Folder.Items(0), _
ShellFolderItem).Path))
End If
End If
Next
End Sub
Sub Timer_Job() Handles RoutineTimer.Tick
GetOpenedFolder()
End Sub
Function TrimPath(ByRef s As String) As String
Return s.Remove(InStrRev(s, "\"))
End Function
End Class
The code will generate a timer and listbox in the form, so you don't have to adding control in the form. you can modify the code to running like a "On Access Scanner Program", have a nice program :-)
To test the program, Open two or more explorer, and then start the program.. and see what you get.
if you need to download the project, CLICK HERE TO DOWNLOAD
1 comments:
hello, Is there a way to do this but in batch?
Could someone tell me how it can be done?
Post a Comment