使用Shell關閉指定資料夾視窗

2022-06-10 11:12:11 字數 687 閱讀 6995

使用shell物件的com api可以檢索和識別檔案資源管理器視窗,涉及到的com引用為:microsoft shell controls and automation,microsoft internet controls。引入後,他們分別引用了interop.shell32.dll、interop.shdocvw.dll。

shell.windows方法返回ienumerable物件,它裡面的成員是shdocvw.internetexplorer型別例項,如果它的document屬性是shell32.shellfolderview型別,那麼該物件就是檔案管理器物件。根據shell32.shellfolderview物件的folder屬性,可以處理不同的檔案管理器需求。

參考資料

/// /// 關閉資料夾視窗

///

/// 資料夾視窗名稱

public static void closeexplorerwindows(string windowname)

var shell = new shell32.shell();

// ref: shell.windows method

// var windows = shell.windows() as system.collections.ienumerable;

if (windows != null)}}

}

列舉資料夾,列舉指定資料夾

一 列舉資料夾函式 void specialfolder browse hwnd hwnd clean up.g pmalloc free pidlspecialfolder g pmalloc free lpbuffer release the shell s allocator.g pmallo...

CMD刪除指定資料夾

2018年10月16日 14 07 34 草巾冒小子 閱讀數 7114更多 分類專欄 cmd 有的專案檔案查詢比較繁瑣,而且有時候執行刪除之後檔案仍有殘留。想來有此更便捷的刪除之法。執行後會永久刪除檔案。如上圖所示 鍵盤執行輸入rd s q,然後空格,然後是檔案物理路徑 以上就是關於 cmd刪除指定...

CMD刪除指定資料夾

2018年10月16日 14 07 34 草巾冒小子 閱讀數 7114更多 分類專欄 cmd 有的專案檔案查詢比較繁瑣,而且有時候執行刪除之後檔案仍有殘留。想來有此更便捷的刪除之法。執行後會永久刪除檔案。如上圖所示 鍵盤執行輸入rd s q,然後空格,然後是檔案物理路徑 以上就是關於 cmd刪除指定...