Skip to content
⌘ NSIS Forum Archive

Strange value returned from Processes::FindProcess

3 posts

Downward FG#

Strange value returned from Processes::FindProcess

I am using this plug-in to determine if any of the applications I am installing add-ons for are currently running, and asking the user to quit them or abort the installation.

It usually works great, but intermittently it asks the user to quit a process that isn't running? For some users it isn't even installed. I checked the return value of Process::FindProcess, and when first called it returns an abitrary integer i.e. not 0 or 1.

Code sample given:
  strcpy $proc1 ""
  strcpy $proc2 ""
  strcpy $procrunning ""
Processes::FindProcess "proc1.exe"
  Pop $R0
  StrCmp $R0 "0" skip1
  strcpy $proc1 "$\n$(Process1_local_name)"
  strcpy $procrunning "true"
  Pop $R0
Skip1:
  Processes::FindProcess "proc2.exe"
  Pop $R0
  StrCmp $R0 "0" skip2
  strcpy $proc2 "$\n$(Process2_local_name)"
  strcpy $procrunning "true"  
  Pop $R0
Skip2:
StrCmp $procrunning "true" ProcessFound ProcessQuit
ProcessFound:  
  MessageBox MB_ICONEXCLAMATION|MB_RETRYCANCEL|MB_TOPMOST "$(Local_Message) $proc1 $proc2 " /SD IDCANCEL IDRETRY ProcessCheck
abort
ProcessQuit: 
It is always the first call that returns the strange value. If the user selects retry it always it works fine. Any clues as to what might cause this.

I have tried copying "0" into $R0 before I make the first call, and it still happens.
Afrow UK#
According to the wiki page, the plug-in stores its output in $R0 therefore you should not be popping to $R0 at all. The value you are getting in $R0 is on the stack from something else completely.

Stu