NSIS-FindProc 总是返回 1 [英] NSIS- FindProc always returns 1

查看:106
本文介绍了NSIS-FindProc 总是返回 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7 上使用 此处定义的宏,但它总是返回 1.

I'm using the macro defined here, on Windows 7, however it always returns 1.

我是这样称呼它的:

!insertmacro FindProc $processFound "MyApp.exe"
MessageBox MB_OK $processFound
IntCmp $processFound ${FindProc_FOUND} +1 +3 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please close the app before running this setup." /SD IDOK
Abort

与使用 WMI 相比,这似乎相当简单,并且同一页面上列出的 FindProcDLL 方法不再起作用(即使是 NSIS Unicode 版本).那么为什么这个方法总是返回 1 呢?我已经单独验证了

This seems fairly simple compared to messing around with WMI, and the FindProcDLL method listed on the same page doesn't work anymore (even the NSIS Unicode version). So why would this method always return 1? I've separately verified that

tasklist /nh /fi "IMAGENAME eq MyApp.exe"  | find /i "MyApp.exe"

根据应用是否正在运行返回 1 和 0.

returns 1 and 0 depending on whether the app is running or not.

更新:我使用 ExecWait 得到了相同的结果.

Update: I've used ExecWait with the same result.

更新 2:尝试使用 此处 中的 nsProcess,如下所示 -

Update 2 : Tried using nsProcess from here, as below -

nsProcess::_FindProcess "myprogram.exe" $R0
MessageBox MB_OK $R0

这总是显示为空白.我没有在其他任何地方声明 $R0.是否存在语法错误,或者这在 Windows 7 上也不起作用?

This always shows up as blank. I have not declared $R0 anywhere else. Is there a syntax error somewhere, or is this also not working on Windows 7?

推荐答案

给 Anders 的帽子提示 - 我忘了弹出函数调用的结果.代码现在可以工作了,看起来像这样:

Hat tip to Anders - I forgot to Pop the result of the function call. The code now works, and looks like this:

nsProcess::_FindProcess "UID.EnrolmentClient.exe" $R0
Pop $0
StrCmp $0 "0" +1 +3
MessageBox MB_ICONEXCLAMATION|MB_OK "Please close the application before running this setup." /SD IDOK
Abort

这篇关于NSIS-FindProc 总是返回 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆