開啟資料夾並且選中指定的檔案的通用函式

2021-04-13 08:52:14 字數 836 閱讀 7942

'程式設計:唐細剛  2006-4-19 at shenzhen

'函式:openfolderandselectspecialfile

'用途:開啟指定的資料夾並且選中指定的檔案

'引數:szspecialfileforselect 想要選中的檔案全路徑

'返回:true:選中檔案成功 false: 選中檔案失敗或者指定檔案不存在

public function openfolderandselectspecialfile(byval szspecialfileforselect as string) as boolean

on error goto herr

if dir(szspecialfileforselect) <> "" then

dim szshellselect as string

szshellselect = "explorer /select, "

szshellselect = szshellselect & szspecialfileforselect

shell szshellselect, vbnormalfocus

openfolderandselectspecialfile = true

end if

exit function

herr:

end function

'呼叫舉例:

private sub command1_click()

call openfolderandselectspecialfile("c:/program files/internet explorer/iexplore.exe")

end sub

開啟資料夾並且選中指定的檔案的通用函式

程式設計 唐細剛 2006 4 19 at shenzhen 函式 openfolderandselectspecialfile 用途 開啟指定的資料夾並且選中指定的檔案 引數 szspecialfileforselect 想要選中的檔案全路徑 返回 true 選中檔案成功 false 選中檔案失敗...

Java如何開啟乙個資料夾並選中指定檔案

很簡單,呼叫explorer.exe就可以,runtime.getruntime exec rundll32 shell32.dll,shellexec rundll explorer.exe select,targetdirectfilename windows explorer switches...

C 開啟指定資料夾,並選中檔案

今天寫 的時候需要乙個開啟指定資料夾並選中檔案的功能,於是乎就度娘了一下,找到了 2中方法,遂記之以留後用 這裡也順便給大家分享一下.這個方法很簡單,實際上是在 c 中呼叫了 windows 的shell 命令 explorer 例如下面我在控制台下通過這個命令開啟c盤的 windows 資料夾並且...