Win32 快捷方式操作助手类(Lnk快捷方式)

2024-01-25 00:44

本文主要是介绍Win32 快捷方式操作助手类(Lnk快捷方式),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

将快捷方式的操作做了一个简单封装, 方便使用.

//解析Lnk内容
{CLnkHelper obj;obj.Load(_T("123.lnk"));SHELL_LINK_INFO info = obj.GetInfo();//TODO 使用info的内容
}//创建(另存为)快捷方式
{CLnkHelper obj;SHELL_LINK_INFO info;//TODO 修改info的内容obj.SetInfo(info);obj.Save(_T("456.lnk"));
}

CLnkHelper.h

#pragma once#include <stdint.h>
#include <string>
#include <shobjidl.h>#ifdef _UNICODE
using _tstring = std::wstring;
using _tfstream = std::wfstream;
#else
using _tstring = std::string;
using _tfstream = std::fstream;
#endiftypedef struct _SHELL_LINK_INFO
{_tstring strFile;       //目标路径_tstring strDesc;       //描述_tstring strArgs;       //参数_tstring strDir;        //工作目录_tstring strIconPath;   //图标路径_tstring strPathRel;    //相对路径WORD wHotkey;           //快捷键int iShowCmd;           //显示命令int iIcon;              //图标索引_SHELL_LINK_INFO():wHotkey(0),iShowCmd(0),iIcon(0){}}SHELL_LINK_INFO;class CLnkHelper
{
public:CLnkHelper();~CLnkHelper();//// @brief: 加载快捷方式// @param: strFile          文件路径// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/objidl/nf-objidl-ipersistfile-load}.bool Load(const _tstring& strFile);//// @brief: 快捷方式保存// @param: strFile          文件路径// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/objidl/nf-objidl-ipersistfile-save}.bool Save(const _tstring& strFile);//// @brief: 获取信息// @param: void// @ret: SHELL_LINK_INFO    信息内容SHELL_LINK_INFO GetInfo() const;//// @brief: 设置信息// @param: info             信息内容// @ret: bool               操作结果bool SetInfo(const SHELL_LINK_INFO& info);//// @remark // @brief: 尝试查找快捷方式目标// @param: hwnd             对话框的父窗口的句柄// @param: fFlags           操作标志// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-resolve}.bool Resolve(HWND hwnd, DWORD fFlags = SLR_NO_UI);//// @brief: 获取/设置目标路径// @param: strFile          目标路径// @param: fFlags           路径类型标志(SLGP_SHORTPATH, SLGP_RAWPATH, SLGP_RELATIVEPRIORITY)// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-getpath}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setpath}.bool GetPath(_tstring& strFile, DWORD fFlags = SLGP_RAWPATH) const;_tstring GetPath(DWORD fFlags = SLGP_RAWPATH) const;bool SetPath(const _tstring& strFile);//// @brief: 获取/设置描述文本// @param: strDesc          描述文本// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-getdescription}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setdescription}.bool GetDescription(_tstring& strDesc) const;_tstring GetDescription() const;bool SetDescription(const _tstring& strDesc);//// @brief: 获取/设置工作目录// @param: strDir           工作目录// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-getworkingdirectory}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setworkingdirectory}.bool GetWorkingDirectory(_tstring& strDir) const;_tstring GetWorkingDirectory() const;bool SetWorkingDirectory(const _tstring& strDir);//// @brief: 获取/设置命令行参数// @param: strArgs          命令行参数// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-getarguments}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setarguments}.bool GetArguments(_tstring& strArgs) const;_tstring GetArguments() const;bool SetArguments(const _tstring& strArgs);//// @brief: 获取/设置快捷键// @param: bModifier        修饰键(HOTKEYF_ALT, HOTKEYF_CONTROL, HOTKEYF_EXT, HOTKEYF_SHIFT)// @param: bKey             普通键// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-gethotkey}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-sethotkey}.bool GetHotkey(BYTE& bModifier, BYTE& bKey) const;WORD GetHotkey() const;bool SetHotkey(BYTE bModifier, BYTE bKey);bool SetHotkey(WORD wHotkey);//// @brief: 获取/设置显示命令// @param: iShowCmd         显示命令(SW_SHOWNORMAL, SW_SHOWMAXIMIZED, SW_SHOWMINIMIZED)// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-getshowcmd}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setshowcmd}.bool CLnkHelper::GetShowCmd(int& iShowCmd) const;int CLnkHelper::GetShowCmd() const;bool CLnkHelper::SetShowCmd(int iShowCmd);//// @brief: 获取/设置图标位置// @param: strIconPath      图标路径// @param: iIcon            图标索引// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-geticonlocation}.// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-seticonlocation}.bool GetIconLocation(_tstring& strIconPath, int& iIcon) const;_tstring GetIconLocation(int* piIcon = nullptr) const;bool SetIconLocation(const _tstring& IconPath, int iIcon);//// @brief: 设置相对路径// @param: strPathRel       相对路径// @ret: bool               操作结果// {@link https://learn.microsoft.com/zh-cn/windows/win32/api/shobjidl_core/nf-shobjidl_core-ishelllinka-setrelativepath}.bool GetRelativePath(_tstring& strPathRel) const;_tstring GetRelativePath() const;bool SetRelativePath(const _tstring& strPathRel);private://// @brief: 初始化// @ret: bool               操作结果bool Initialized();//// @brief: 反初始化// @ret: void               无void Uninitialize();private:IShellLink* m_SheelLink;    //Shell 链接接口对象指针IPersistFile* m_ppf;        //存储链接信息接口对象指针bool m_bInit;
};

CLnkHelper.cpp

#include "CLnkHelper.h"
#include <shlguid.h>CLnkHelper::CLnkHelper():m_SheelLink(nullptr),m_ppf(nullptr),m_bInit(false)
{this->Initialized();
}CLnkHelper::~CLnkHelper()
{this->Uninitialize();
}bool CLnkHelper::Initialized()
{HRESULT hr = S_OK;hr = ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);if (FAILED(hr)){return false;}m_bInit = true;hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&m_SheelLink);if (FAILED(hr)){return false;}hr = m_SheelLink->QueryInterface(IID_IPersistFile, (void**)&m_ppf);if (FAILED(hr)){return false;}return true;
}void CLnkHelper::Uninitialize()
{if (m_ppf){m_ppf->Release();m_ppf = nullptr;}if (m_SheelLink){m_SheelLink->Release();m_SheelLink = nullptr;}if (m_bInit){(void)::CoUninitialize();}
}bool CLnkHelper::Load(const _tstring& strFile)
{HRESULT hr = S_OK;if (!m_ppf){return false;}hr = m_ppf->Load(strFile.c_str(), STGM_READWRITE);if (FAILED(hr)){return false;}return true;
}bool CLnkHelper::Save(const _tstring& strFile)
{HRESULT hr = S_OK;if (!m_ppf){return false;}hr = m_ppf->Save(strFile.c_str(), true);return SUCCEEDED(hr);
}SHELL_LINK_INFO CLnkHelper::GetInfo() const
{SHELL_LINK_INFO info;if (m_SheelLink){WIN32_FIND_DATA wfd = { 0 };TCHAR szBuf[MAX_PATH * 4] = { 0 };HRESULT hr = S_OK;hr = m_SheelLink->GetPath(szBuf, _countof(szBuf), &wfd, SLGP_RAWPATH);if (SUCCEEDED(hr)){info.strFile = szBuf;}hr = m_SheelLink->GetPath(szBuf, _countof(szBuf), &wfd, SLGP_RELATIVEPRIORITY);if (SUCCEEDED(hr)){info.strPathRel = szBuf;}hr = m_SheelLink->GetDescription(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){info.strDesc = szBuf;}hr = m_SheelLink->GetWorkingDirectory(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){info.strDir = szBuf;}hr = m_SheelLink->GetArguments(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){info.strArgs = szBuf;}int iIcon = 0;hr = m_SheelLink->GetIconLocation(szBuf, _countof(szBuf), &iIcon);if (SUCCEEDED(hr)){info.strIconPath = szBuf;info.iIcon = iIcon;}int iShowCmd = 0;hr = m_SheelLink->GetShowCmd(&iShowCmd);if (SUCCEEDED(hr)){info.iShowCmd = iShowCmd;}WORD wHotkey = 0;hr = m_SheelLink->GetHotkey(&wHotkey);if (SUCCEEDED(hr)){info.wHotkey = wHotkey;}}return info;
}bool CLnkHelper::SetInfo(const SHELL_LINK_INFO& info)
{if (!m_SheelLink){return false;}m_SheelLink->SetPath(info.strFile.c_str());m_SheelLink->SetRelativePath(info.strPathRel.c_str(), 0);m_SheelLink->SetDescription(info.strDesc.c_str());m_SheelLink->SetArguments(info.strArgs.c_str());m_SheelLink->SetIconLocation(info.strIconPath.c_str(), info.iIcon);m_SheelLink->SetWorkingDirectory(info.strDir.c_str());m_SheelLink->SetHotkey(info.wHotkey);m_SheelLink->SetShowCmd(info.iShowCmd);return true;
}bool CLnkHelper::Resolve(HWND hwnd, DWORD fFlags)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->Resolve(hwnd, fFlags);return SUCCEEDED(hr);
}bool CLnkHelper::GetPath(_tstring& strFile, DWORD fFlags/* = SLGP_RAWPATH*/) const
{if (!m_SheelLink){return false;}WIN32_FIND_DATA wfd = { 0 };TCHAR szBuf[MAX_PATH * 4] = { 0 };HRESULT hr = S_OK;hr = m_SheelLink->GetPath(szBuf, _countof(szBuf), &wfd, fFlags);if (SUCCEEDED(hr)){strFile = szBuf;}return SUCCEEDED(hr);
}_tstring CLnkHelper::GetPath(DWORD fFlags/* = SLGP_RAWPATH*/) const
{if (!m_SheelLink){return _tstring();}WIN32_FIND_DATA wfd = { 0 };TCHAR szBuf[MAX_PATH * 4] = { 0 };HRESULT hr = S_OK;hr = m_SheelLink->GetPath(szBuf, _countof(szBuf), &wfd, fFlags);if (SUCCEEDED(hr)){return szBuf;}return _tstring();
}bool CLnkHelper::SetPath(const _tstring& strFile)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetPath(strFile.c_str());return SUCCEEDED(hr);
}bool CLnkHelper::GetDescription(_tstring& strDesc) const
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetDescription(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){strDesc = szBuf;}return SUCCEEDED(hr);
}_tstring CLnkHelper::GetDescription() const
{if (!m_SheelLink){return _tstring();}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetDescription(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){return szBuf;}return _tstring();
}bool CLnkHelper::SetDescription(const _tstring& strDesc)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetDescription(strDesc.c_str());return SUCCEEDED(hr);
}bool CLnkHelper::GetWorkingDirectory(_tstring& strDir) const
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetWorkingDirectory(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){strDir = szBuf;}return SUCCEEDED(hr);
}_tstring CLnkHelper::GetWorkingDirectory() const
{if (!m_SheelLink){return _tstring();}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetWorkingDirectory(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){return szBuf;}return _tstring();
}bool CLnkHelper::SetWorkingDirectory(const _tstring& strDir)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetWorkingDirectory(strDir.c_str());return SUCCEEDED(hr);
}bool CLnkHelper::GetArguments(_tstring& strArgs) const
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetArguments(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){strArgs = szBuf;}return SUCCEEDED(hr);
}_tstring CLnkHelper::GetArguments() const
{if (!m_SheelLink){return _tstring();}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetArguments(szBuf, _countof(szBuf));if (SUCCEEDED(hr)){return szBuf;}return _tstring();
}bool CLnkHelper::SetArguments(const _tstring& strArgs)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetArguments(strArgs.c_str());return SUCCEEDED(hr);
}bool CLnkHelper::GetHotkey(BYTE& bModifier, BYTE& bKey) const
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;WORD wHotkey = 0;hr = m_SheelLink->GetHotkey(&wHotkey);if (SUCCEEDED(hr)){bModifier = HIBYTE(wHotkey);bKey = LOBYTE(wHotkey);}return SUCCEEDED(hr);
}WORD CLnkHelper::GetHotkey() const
{if (!m_SheelLink){return 0;}HRESULT hr = S_OK;WORD wHotkey = 0;hr = m_SheelLink->GetHotkey(&wHotkey);if (SUCCEEDED(hr)){return wHotkey;}return 0;
}bool CLnkHelper::SetHotkey(BYTE bModifier, BYTE bKey)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetHotkey(MAKEWORD(bKey, bModifier));return SUCCEEDED(hr);
}bool CLnkHelper::SetHotkey(WORD wHotkey)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetHotkey(wHotkey);return SUCCEEDED(hr);
}bool CLnkHelper::GetShowCmd(int& iShowCmd) const
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->GetShowCmd(&iShowCmd);return SUCCEEDED(hr);
}int CLnkHelper::CLnkHelper::GetShowCmd() const
{if (!m_SheelLink){return 0;}HRESULT hr = S_OK;int iShowCmd = 0;hr = m_SheelLink->GetShowCmd(&iShowCmd);if (SUCCEEDED(hr)){return iShowCmd;}return 0;
}bool CLnkHelper::SetShowCmd(int iShowCmd)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetShowCmd(iShowCmd);return SUCCEEDED(hr);
}bool CLnkHelper::GetIconLocation(_tstring& IconPath, int& iIcon) const
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };hr = m_SheelLink->GetIconLocation(szBuf, _countof(szBuf), &iIcon);if (SUCCEEDED(hr)){IconPath = szBuf;}return SUCCEEDED(hr);
}_tstring CLnkHelper::GetIconLocation(int* piIcon/* = nullptr*/) const
{if (!m_SheelLink){return _tstring();}HRESULT hr = S_OK;TCHAR szBuf[MAX_PATH * 4] = { 0 };int iIcon = 0;hr = m_SheelLink->GetIconLocation(szBuf, _countof(szBuf), &iIcon);if (SUCCEEDED(hr)){if (piIcon){*piIcon = iIcon;}return szBuf;}return _tstring();
}bool CLnkHelper::SetIconLocation(const _tstring& IconPath, int iIcon)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetIconLocation(IconPath.c_str(), iIcon);return SUCCEEDED(hr);
}bool CLnkHelper::GetRelativePath(_tstring& strPathRel) const
{if (!m_SheelLink){return false;}WIN32_FIND_DATA wfd = { 0 };TCHAR szBuf[MAX_PATH * 4] = { 0 };HRESULT hr = S_OK;hr = m_SheelLink->GetPath(szBuf, _countof(szBuf), &wfd, SLGP_RELATIVEPRIORITY);if (SUCCEEDED(hr)){strPathRel = szBuf;}return SUCCEEDED(hr);
}_tstring CLnkHelper::GetRelativePath() const
{if (!m_SheelLink){return _tstring();}WIN32_FIND_DATA wfd = { 0 };TCHAR szBuf[MAX_PATH * 4] = { 0 };HRESULT hr = S_OK;hr = m_SheelLink->GetPath(szBuf, _countof(szBuf), &wfd, SLGP_RELATIVEPRIORITY);if (SUCCEEDED(hr)){return szBuf;}return _tstring();
}bool CLnkHelper::SetRelativePath(const _tstring& strRelativePath)
{if (!m_SheelLink){return false;}HRESULT hr = S_OK;hr = m_SheelLink->SetRelativePath(strRelativePath.c_str(), 0);return SUCCEEDED(hr);
}

测试

main.cpp

#include <iostream>
#include <vector>
#include <map>
#include <stdarg.h>
#include <tchar.h>
#include <windows.h>
#include <thread>
#include <strsafe.h>
#include "Win32Utils/CLnkHelper.h"
#include "Win32Utils/CPathUtils.h"int _tmain(int argc, LPCTSTR argv[])
{setlocale(LC_ALL, "");CLnkHelper obj;obj.Load(_T("123.lnk"));SHELL_LINK_INFO info = obj.GetInfo();obj.SetInfo(info);obj.Save(_T("123.lnk"));return 0;
}

这篇关于Win32 快捷方式操作助手类(Lnk快捷方式)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/641575

相关文章

Go异常处理、泛型和文件操作实例代码

《Go异常处理、泛型和文件操作实例代码》Go语言的异常处理机制与传统的面向对象语言(如Java、C#)所使用的try-catch结构有所不同,它采用了自己独特的设计理念和方法,:本文主要介绍Go异... 目录一:异常处理常见的异常处理向上抛中断程序恢复程序二:泛型泛型函数泛型结构体泛型切片泛型 map三:文

MySQL基本表查询操作汇总之单表查询+多表操作大全

《MySQL基本表查询操作汇总之单表查询+多表操作大全》本文全面介绍了MySQL单表查询与多表操作的关键技术,包括基本语法、高级查询、表别名使用、多表连接及子查询等,并提供了丰富的实例,感兴趣的朋友跟... 目录一、单表查询整合(一)通用模版展示(二)举例说明(三)注意事项(四)Mapper简单举例简单查询

Nginx概念、架构、配置与虚拟主机实战操作指南

《Nginx概念、架构、配置与虚拟主机实战操作指南》Nginx是一个高性能的HTTP服务器、反向代理服务器、负载均衡器和IMAP/POP3/SMTP代理服务器,它支持高并发连接,资源占用低,功能全面且... 目录Nginx 深度解析:概念、架构、配置与虚拟主机实战一、Nginx 的概念二、Nginx 的特点

MySQL 数据库进阶之SQL 数据操作与子查询操作大全

《MySQL数据库进阶之SQL数据操作与子查询操作大全》本文详细介绍了SQL中的子查询、数据添加(INSERT)、数据修改(UPDATE)和数据删除(DELETE、TRUNCATE、DROP)操作... 目录一、子查询:嵌套在查询中的查询1.1 子查询的基本语法1.2 子查询的实战示例二、数据添加:INSE

使用Python在PDF中绘制多种图形的操作示例

《使用Python在PDF中绘制多种图形的操作示例》在进行PDF自动化处理时,人们往往首先想到的是文本生成、图片嵌入或表格绘制等常规需求,然而在许多实际业务场景中,能够在PDF中灵活绘制图形同样至关重... 目录1. 环境准备2. 创建 PDF 文档与页面3. 在 PDF 中绘制不同类型的图形python

Java 操作 MinIO详细步骤

《Java操作MinIO详细步骤》本文详细介绍了如何使用Java操作MinIO,涵盖了从环境准备、核心API详解到实战场景的全过程,文章从基础的桶和对象操作开始,到大文件分片上传、预签名URL生成... 目录Java 操作 MinIO 全指南:从 API 详解到实战场景引言:为什么选择 MinIO?一、环境

在DataGrip中操作MySQL完整流程步骤(从登录到数据查询)

《在DataGrip中操作MySQL完整流程步骤(从登录到数据查询)》DataGrip是JetBrains公司出品的一款现代化数据库管理工具,支持多种数据库系统,包括MySQL,:本文主要介绍在D... 目录前言一、登录 mysql 服务器1.1 打开 DataGrip 并添加数据源1.2 配置 MySQL

Go语言中如何进行数据库查询操作

《Go语言中如何进行数据库查询操作》在Go语言中,与数据库交互通常通过使用数据库驱动来实现,Go语言支持多种数据库,如MySQL、PostgreSQL、SQLite等,每种数据库都有其对应的官方或第三... 查询函数QueryRow和Query详细对比特性QueryRowQuery返回值数量1个:*sql

Python操作Excel的实用工具与库openpyxl/pandas的详细指南

《Python操作Excel的实用工具与库openpyxl/pandas的详细指南》在日常数据处理工作中,Excel是最常见的数据文件格式之一,本文将带你了解openpyxl和pandas的核心用法,... 目录一、openpyxl:原生 Excel 文件操作库1. 安装 openpyxl2. 创建 Exc

Python实现Word文档自动化的操作大全(批量生成、模板填充与内容修改)

《Python实现Word文档自动化的操作大全(批量生成、模板填充与内容修改)》在职场中,Word文档是公认的好伙伴,但你有没有被它折磨过?批量生成合同、制作报告以及发放证书/通知等等,这些重复、低效... 目录重复性文档制作,手动填充模板,效率低下还易错1.python-docx入门:Word文档的“瑞士