linux获取lnk文件的源目标路径,在Python中读取.lnk文件的目标?

基本上是直接调用Windows API。以下是在谷歌搜索后发现的一个很好的例子:import os, sys

import pythoncom

from win32com.shell import shell, shellcon

shortcut = pythoncom.CoCreateInstance (

shell.CLSID_ShellLink,

None,

pythoncom.CLSCTX_INPROC_SERVER,

shell.IID_IShellLink

)

desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)

shortcut_path = os.path.join (desktop_path, "python.lnk")

persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile)

persist_file.Load (shortcut_path)

shortcut.SetDescription ("Updated Python %s" % sys.version)

mydocs_path = shell.SHGetFolderPath (0, shellcon.CSIDL_PERSONAL, 0, 0)

shortcut.SetWorkingDirectory (mydocs_path)

persist_file.Save (shortcut_path, 0)

您可以在“python ishelllink”中搜索其他示例。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值