farstaryao
小水手

UID 24237
精华
0
积分 13
帖子 13
阅读权限 10
注册 2006-10-18
状态 离线
|
道德要与自定义的类型扩展名建立链接,再在系统启动时判断
下面是我自己写的一个扩展名链接程序,希望对你有用:
Public Function SetLinkType(ByRef sTypeName As String, ByRef sEXEName As String, ByRef sIconPath As String, Optional sNoteofType As String) As Long
'设置sTypeName文件格式为sNoteofType的文件格式
'sExeName为你的可执行文件的名称
'sIconPath为你要用的显示图标路径
Dim hKey As Long, PathName As String
Dim NotepadDir As String, IconDir As String
PathName = App.Path
If Right(PathName, 1) <> "\" Then PathName = PathName & "\"
' IconDir = PathName & "Cdrom01.ico,0"
IconDir = sIconPath & ",0"
PathName = PathName & sEXEName & ".exe %1"
NotepadDir = String(MAX_PATH, Chr(0)) '添加“打印”
GetWindowsDirectory NotepadDir, Len(NotepadDir)
NotepadDir = Left(NotepadDir, InStr(NotepadDir, Chr(0)) - 1)
If Right(NotepadDir, 1) <> "\" Then NotepadDir = NotepadDir & "\"
NotepadDir = NotepadDir & "Notepad.EXE /p %1"
hKey = HKEY_CLASSES_ROOT
RegSetValue hKey, sTypeName, REG_SZ, "fslFile", 8
RegSetValue hKey, "fslFile", REG_SZ, sEXEName & sNoteofType, 20
RegSetValue hKey, "fslFile\shell", REG_SZ, "open", 5
RegSetValue hKey, "fslFile\shell\open\command", REG_SZ, _
PathName, LenB(StrConv(PathName, vbFromUnicode)) + 1
RegSetValue hKey, "fslFile\shell\print\command", REG_SZ, _
NotepadDir, LenB(StrConv(NotepadDir, vbFromUnicode)) + 1
RegSetValue hKey, "fslFile\DefaultIcon", REG_SZ, _
IconDir, LenB(StrConv(IconDir, vbFromUnicode)) + 1
RegCloseKey hKey
End Function
Public Function GetLinkFileName() As String
'取得双击文件而打开的文件名
'如果返回值为空则没有双击文件或未成功
'相反则返回双击启动的文件名
'可在系统启动时调用该函数
Dim barr() As Byte
Dim iFN As Integer
iFN = FreeFile
Open Command For Input As #iFN
barr = InputB(LOF(1), 1)
GetLinkFileName = Trim(StrConv(barr, vbUnicode)) '取出列表文件中的各文件名
Close #iFN
End Function
|  多多指教 |
|