タイトル | : Re: エクスプローラでフルパス名検知 |
記事No | : 13239 |
投稿日 | : 2008/11/14(Fri) 16:12 |
投稿者 | : 魔界の仮面弁士 |
> ユーザがWindowsエクスプローラのファイル名をクリックした際、 使うとすれば、ShellFolderView オブジェクトの SelectionChanged イベントかな。 http://msdn.microsoft.com/en-us/library/bb774045.aspx
> そのフルパス名を得る方法を教えてください。 ShellFolderView オブジェクトの FocusedItem プロパティ/SelectedItems メソッドから 選択されている FolderItem オブジェクトを取得して、その Path を得るとか。
Option Explicit
Private WithEvents FolderView As Shell32.ShellFolderView Private WithEvents Explorer As SHDocVw.InternetExplorer
Private Sub Explorer_BeforeNavigate2( _ ByVal pDisp As Object, URL As Variant, Flags As Variant, _ TargetFrameName As Variant, PostData As Variant, _ Headers As Variant, Cancel As Boolean) Set FolderView = Nothing End Sub
Private Sub Explorer_DocumentComplete(ByVal pDisp As Object, URL As Variant) On Error Resume Next Set FolderView = Explorer.Document End Sub
Private Sub Explorer_OnQuit() Set FolderView = Nothing Set Explorer = Nothing Unload Me End Sub
Private Sub Form_Load() On Error Resume Next Set Explorer = GetObject("new:{C08AFD90-F2A1-11D1-8455-00A0C91F3880}") Explorer.Navigate2 0& Explorer.ShowBrowserBar "{EFA24E64-B078-11D0-89E4-00C04FC9E26E}", True Explorer.Visible = True End Sub
Private Sub FolderView_SelectionChanged() On Error Resume Next Dim fis As Shell32.FolderItems Set fis = FolderView.SelectedItems()
List1.Clear If fis.Count > 0 Then Dim fi As Shell32.FolderItem For Each fi In fis List1.AddItem fi.Path Next End If End Sub
Private Sub Form_Unload(Cancel As Integer) Set FolderView = Nothing If Not Explorer Is Nothing Then On Error Resume Next Explorer.Quit Set Explorer = Nothing End If End Sub
|