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

相关文章

让树莓派智能语音助手实现定时提醒功能

最初的时候是想直接在rasa 的chatbot上实现,因为rasa本身是带有remindschedule模块的。不过经过一番折腾后,忽然发现,chatbot上实现的定时,语音助手不一定会有响应。因为,我目前语音助手的代码设置了长时间无应答会结束对话,这样一来,chatbot定时提醒的触发就不会被语音助手获悉。那怎么让语音助手也具有定时提醒功能呢? 我最后选择的方法是用threading.Time

ASIO网络调试助手之一:简介

多年前,写过几篇《Boost.Asio C++网络编程》的学习文章,一直没机会实践。最近项目中用到了Asio,于是抽空写了个网络调试助手。 开发环境: Win10 Qt5.12.6 + Asio(standalone) + spdlog 支持协议: UDP + TCP Client + TCP Server 独立的Asio(http://www.think-async.com)只包含了头文件,不依

动手学深度学习【数据操作+数据预处理】

import osos.makedirs(os.path.join('.', 'data'), exist_ok=True)data_file = os.path.join('.', 'data', 'house_tiny.csv')with open(data_file, 'w') as f:f.write('NumRooms,Alley,Price\n') # 列名f.write('NA

线程的四种操作

所属专栏:Java学习        1. 线程的开启 start和run的区别: run:描述了线程要执行的任务,也可以称为线程的入口 start:调用系统函数,真正的在系统内核中创建线程(创建PCB,加入到链表中),此处的start会根据不同的系统,分别调用不同的api,创建好之后的线程,再单独去执行run(所以说,start的本质是调用系统api,系统的api

Java IO 操作——个人理解

之前一直Java的IO操作一知半解。今天看到一个便文章觉得很有道理( 原文章),记录一下。 首先,理解Java的IO操作到底操作的什么内容,过程又是怎么样子。          数据来源的操作: 来源有文件,网络数据。使用File类和Sockets等。这里操作的是数据本身,1,0结构。    File file = new File("path");   字

MySQL——表操作

目录 一、创建表 二、查看表 2.1 查看表中某成员的数据 2.2 查看整个表中的表成员 2.3 查看创建表时的句柄 三、修改表 alter 3.1 重命名 rename 3.2 新增一列 add 3.3 更改列属性 modify 3.4 更改列名称 change 3.5 删除某列 上一篇博客介绍了库的操作,接下来来看一下表的相关操作。 一、创建表 create

封装MySQL操作时Where条件语句的组织

在对数据库进行封装的过程中,条件语句应该是相对难以处理的,毕竟条件语句太过于多样性。 条件语句大致分为以下几种: 1、单一条件,比如:where id = 1; 2、多个条件,相互间关系统一。比如:where id > 10 and age > 20 and score < 60; 3、多个条件,相互间关系不统一。比如:where (id > 10 OR age > 20) AND sco

PHP7扩展开发之流操作

前言 啥是流操作?简单来讲就是对一些文件,网络的IO操作。PHP已经把这些IO操作,封装成流操作。这节,我们将使用PHP扩展实现一个目录遍历的功能。PHP示例代码如下: <?phpfunction list_dir($dir) {if (is_dir($dir) === false) {return;} $dh = opendir($dir);if ($dh == false) {ret

浙大数据结构:树的定义与操作

四种遍历 #include<iostream>#include<queue>using namespace std;typedef struct treenode *BinTree;typedef BinTree position;typedef int ElementType;struct treenode{ElementType data;BinTree left;BinTre

浙大数据结构:04-树7 二叉搜索树的操作集

这道题答案都在PPT上,所以先学会再写的话并不难。 1、BinTree Insert( BinTree BST, ElementType X ) 递归实现,小就进左子树,大就进右子树。 为空就新建结点插入。 BinTree Insert( BinTree BST, ElementType X ){if(!BST){BST=(BinTree)malloc(sizeof(struct TNo