快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

奇幻城官网手机版:如何直接开启一个文件



Shell 是用来履行外部的可履行文件

假如是一个文件,那要用ShellExecute来启动预设的程式来开启文件

'HINSTANCE ShellExecute(奇幻城官网手机版

' HWND   hwnd,     // handle to paren奇幻城官网手机版t window

' LPCTSTR lpOperation, // pointer to string that specifies operation to perform

' LPCTSTR lpFile,    // pointer to filename string

' LPTSTR  lpParameters, // pointer to st奇幻城官网手机版ring that specif奇幻城官网手机版ies executable-file parameters

' LPCTSTR lpDirectory, // pointer to string that specifies default directory

' INT   nShowCmd   // whether file is shown when opened

'  );

例:.doc 是由word或wordpad来开启

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _

(ByVal hwnd As Long, ByVal lpOperation As String, _

ByVal lpFile As String, ByVal lpParameters As String, _

ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Const SW_SHOW = 5

ret = ShellExecute(me.hWnd, "open" , "文件完备路径及名称","", "", SW_SHOW

事实上有一个更快的要领,就是应用Start指令,这个指令用法简单

eg. Start mydoc.doc

故,在vb中就是应用 Shell "start my奇幻城官网手机版doc.doc"

若何查看某个文件是和谁相关联呢?例如:.txt是由哪个程式开启,

1.查[HKEY_CLASSES_ROOT\.txt]

取预设值,如本人电脑预设值为 "txtfile"

2.查[HKEY_CLASSES_ROOT\txtfile\shell\open\command]

取预设值,如本人电脑预设值为 "C:\WINDOWS\NOTEPAD.EXE %1"

如斯可知.txt 是内定由NotePad.exe所履行。

注:若step 1.取得的预设值是 "xxxx",则step 2.就是查

[HKEY_CLASSES_ROOT\xxxx\shell\open\command]的预设值

您可能还会对下面的文章感兴趣: