nsis检查进程是否运行和遇到的中文问题

引入nsprocess插件流程

从nsis官网下载nsprocess插件
https://nsis.sourceforge.io/NsProcess_plugin

截屏2024-06-18 12.07.27.png

把下载压缩包里面的Include/nsProcess.nsh 放到 C:\Program Files (x86)\NSIS\Include

把的Plugin/nsProcess.dll 放的 C:\Program Files (x86)\NSIS\Plugins\x86-ansi

把的Plugin/nsProcess.dll 放的 C:\Program Files (x86)\NSIS\Plugins\x86-ansi 并重命名为 nsProcess.dll

在项目.nsi文件中引入 nsProcess.nsh
!include "nsProcess.nsh"

就可以用一下代码判断进程是否运行

    nsProcess::_FindProcess "test.exe"
    Pop $R0
    ${If} $R0 == 0
          MessageBox MB_OK "程序正在运行,请关闭后重试!"
          Quit
    ${EndIf}

中文程序名问题

在实际运行中,发现无论程序有没有运行,都是返回0,后面调试发现改成英文程序名就可以了,就把原本的中文程序名改成英文的。

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
***************************************************************** *** nsProcess NSIS plugin v1.0 *** ***************************************************************** 2005 Shengalts Aleksander aka Instructor (Shengalts@mail.ru) Source function FIND_PROC_BY_NAME based upon the Ravi Kochhar (kochhar@physiology.wisc.edu) code Thanks iceman_k (FindProcDLL plugin) and DITMan (KillProcDLL plugin) for direct me Features: - Find/kill a process by name - Kill all processes with specified name (not only one) - The process name is case-insensitive - Win95/98/ME/NT/2000/XP support - Small plugin size (4,5 Kb) **** Output variables **** .r0-.r9 == $0-$9 .R0-.R9 == $R0-$R9 **** Find process **** nsProcess::FindProcess "[file.exe]" .r0 "[file.exe]" - Process name (e.g. "notepad.exe") .r0 - $0=0 Success $0=603 Process was not currently running $0=605 Unable to load PSAPI.DLL $0=606 Unable to identify system type $0=607 Unsupported OS $0=700 Unable to get procedure address from PSAPI.DLL $0=701 Unable to get process list, EnumProcesses failed $0=702 Unable to load KERNEL32.DLL $0=703 Unable to get procedure address from KERNEL32.DLL $0=704 CreateToolhelp32Snapshot failed **** Kill process **** nsProcess::KillProcess "[file.exe]" .r0 "[file.exe]" - Process name (e.g. "notepad.exe") .r0 - $0=0 Success $0=602 Not all processes terminated successfully $0=603 Process was not currently running $0=604 No permission to terminate process $0=605 Unable to load PSAPI.DLL $0=606 Unable to identify system type $0=607 Unsupported OS $0=700 Unable to get procedure address from PSAPI.DLL $0=701 Unable to get process list, EnumProcesses failed $0=702 Unable to load KERNEL32.DLL $0=703 Unable to get procedure address from KERNEL32.DLL $0=704 CreateToolhelp32Snapshot failed
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值