Python怎么把exe文件固定到任务栏

Python怎么把exe文件固定到任务栏Python怎么把exe文件固定到任务栏

改写成Python

import ctypes

# 定义Windows API函数的参数类型
ctypes.windll.shell32.ShellExecuteW.argtypes = [
    ctypes.c_void_p, ctypes.c_wchar_p, ctypes.c_wchar_p,
    ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_int
]
# 定义Windows API函数的返回类型
ctypes.windll.shell32.ShellExecuteW.restype = ctypes.c_int

# 调用ShellExecute函数来固定快捷方式到任务栏
shortcut_path = r"快捷方式的绝对路径.lnk"

ctypes.windll.shell32.ShellExecuteW(
    0, "TaskbarPin", shortcut_path, None, None, 5
)