如何建立快捷方式以及更改其中的某些参数(在任何文件夹中)?

netbugs 2000-05-31 02:31:00
听说可以用IShellLink接口,但我不知怎样实现。如果IShellLink在VB中不能用,那么如何调用系统API来实现,不用VB做安装盘中的dll。希望能给出示例代码,多谢了!
...全文
329 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
netbugs 2000-07-08
  • 打赏
  • 举报
回复
With SHFileOp
.wFunc = FO_COPY
.pFrom = sSource
.pTo = sDestination
.fFlags = FOF_SILENT Or FOF_NOCONFIRMATION
End With

'and perform the copy
Call SHFileOperation(SHFileOp)
shfileoperation是"Shell32.dll"中的文件操作函数,shfileop.wfunc是文件操作的功能,.wfunc=fo_copy不就是复制文件吗?
Chen_Lin 2000-06-26
  • 打赏
  • 举报
回复
不理解您的意思.
-----------------------------
用几个小时拨号上网找到的资料落了个"只是复制"的名声......
netbugs 2000-06-26
  • 打赏
  • 举报
回复
谢谢chen_lin,但这么多的代码好象只是复制,我想要的是给出命令行、图标等参数就可建立快捷方式。如果不行,直接用文件访问方式来建立或读写lnk文件也行(源代码)。
Chen_Lin 2000-06-11
  • 打赏
  • 举报
回复
你说的对,CSDN上回答的都是用安装盘中的DLL,
应该有API函数调用,见下:
-----------------------以下再BAS中定义-------------------
Public Const ERROR_SUCCESS As Long = 0
Public Const CSIDL_DESKTOP As Long = &H0
Public Const CSIDL_PROGRAMS As Long = &H2
Public Const CSIDL_STARTMENU As Long = &HB
Public Const CSIDL_DESKTOPDIRECTORY As Long = &H10

Public Const FO_COPY As Long = &H2
Public Const FOF_SILENT As Long = &H4
Public Const FOF_RENAMEONCOLLISION As Long = &H8
Public Const FOF_NOCONFIRMATION As Long = &H10

Public Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type

Public Declare Function SHFileOperation Lib "shell32.dll" _
Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long

Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) As Long

Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
pidl As Long) As Long

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)


Public Sub CreateDesktopLink(sSource As String, sDestination As String)

'working variables
Dim sFiles As String
Dim SHFileOp As SHFILEOPSTRUCT

'terminate passed strings with a null
sSource = sSource & Chr$(0)
sDestination = sDestination & Chr$(0)

'set up the options
With SHFileOp
.wFunc = FO_COPY
.pFrom = sSource
.pTo = sDestination
.fFlags = FOF_SILENT Or FOF_NOCONFIRMATION
End With

'and perform the copy
Call SHFileOperation(SHFileOp)

End Sub


Public Function GetSpecialFolder(hWnd As Long, CSIDL As Long) As String

Dim pidl As Long
Dim pos As Long
Dim sPath As String

'fill the pidl with the specified folder item
If SHGetSpecialFolderLocation(hWnd, CSIDL, pidl) = ERROR_SUCCESS Then

'initialize & get the path
sPath = Space$(260)

If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then

'has a null?
pos = InStr(sPath, Chr$(0))

'strip it
If pos Then

'return folder
GetSpecialFolder = Left$(sPath, pos - 1)

End If

Call CoTaskMemFree(pidl)

End If

End If

End Function
----------------------------以下在主程序中----------------
Dim sDeskPath As String
Dim sStartPath As String
Dim sProgramsLinkPath As String

'path to the current user's Programs folder
sStartPath = GetSpecialFolder(Me.hWnd, CSIDL_PROGRAMS)

'path to the current user's Desktop folder
sDeskPath = GetSpecialFolder(Me.hWnd, CSIDL_DESKTOPDIRECTORY)

'from Programs, path to application link
'and application link name
sProgramsLinkPath = "\MyApp\MyApp.lnk"

'create the desktop link with the values
Call CreateDesktopLink(sStartPath & sProgramsLinkPath, sDeskPath)

----------------------结束--------------------------------------
netbugs 2000-06-05
  • 打赏
  • 举报
回复
你们所说的的Dll都是安装盘中的,有没有其他的API函数,不是vb自带的?
tanhl 2000-06-01
  • 打赏
  • 举报
回复
生成快捷方式的示例代码可以在VB5或VB6中的安装程序示例中找到,具体目录为:

SetupKit/Setup1/Setup1.vbp

你可以打开此工程文件,可找到有关声明。
Chen_Lin 2000-06-01
  • 打赏
  • 举报
回复
http://expert.csdn.net/Topic/6924.shtm
Un1 2000-05-31
  • 打赏
  • 举报
回复
这是申明于 Setup1.vbp 中的代码,去看看。

Declare Function OSfCreateShellLink Lib "vb6stkit.dll" Alias "fCreateShellLink" (ByVal lpstrFolderName As String, ByVal lpstrLinkName As String, ByVal lpstrLinkPath As String, ByVal lpstrLinkArguments As String, ByVal fPrivate As Long, ByVal sParent As String) As Long
PowerBI系列之Power Query专题1.  获取数据 数据源种类介绍和获取Excel数据源输入数据和拷贝数据:创建辅助表解析Json/XML数据格式获取Web网页数据和URL添加动态参数连接数据的四种模式:Import、DirectQuery、Live Connection、Dual双 属于混合模式连接数据库:Sql server、 Mysql(直连但是必须先安装一个mysql插件)DirectQuery直连查询:Sql serverODBC方式获取数据表关联或多个Sql或调用存储过程获取数据SQL动态传参和自定义函数: sql使用参数或数据库名称使用参数连接Sharepoint和OneDrive数据源连接Dataset和Dataflow 替换本地数据源为Sharepoint数据源并保留数据处理操作 终止当前数据刷新Loading:Cancel Query数据源设置-重置数据连接凭证PBIDS连接数据源创建和使用报表模块(输入或值列表)利用报表模板和参数控制线下报表数据权限DirectQuery启用自动页面刷新和更改检测管理聚合表提高DirectQuery查询性能动态M查询参数提高DirectQuery查询性能添加数据刷新时间 DateTime.LocalNow()和Getdate()2.  数据清洗和M语言M语言和官方文档介绍PowerQuery查阅M函数:=#shared, Ctrl+Space提示数据清洗之常用技能:提升标题、更改数据类型、保留删除错误或空行,删除重复项、选择列和删除列、填充单元格、合并列、拆分、提取、替换、条件替换、添加自定义列,添加条件列、添加索引列、分组、添加年月日列、追加和合并查询透视和逆透视以及转置合并单元格的Excel文件处理导入文件夹多Excel文件并合并解决多文件合并列顺序不一致使用参数和函数批量导入文件 文本提取文、英文、数字等处理双引号转义 列拆分详解解决列名改变错误解决列丢失错误动态显示、排序和重命名列为所有列名添加前缀列名字母大写和分隔符调整Trim标题列的多余空格如何处理load数据错误为什么load的Excel数据有null空行为什么load的Excel数据标题在第二行灵活添加占位符规范同类相似数据数据按多列排序为分组添加Index序号分组内值合并诊断工具分析数据处理过程PowerQuery小技巧分享 新冠病例活动轨迹地图标识 

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧