64 bit tasklist lookup to see if nodialog.exe is running

61 views
Skip to first unread message

Steve Ripley

unread,
May 17, 2019, 10:46:22 AM5/17/19
to VA Smalltalk
We're running VAST 9.0 and starting to build the 64 bit image on 64 bit machines running Windows 10.
How can we determine if nodialog.exe is running?  I want to prevent the image from being started multiple times on a workstation. 
On the 32 bit image on 32 bit machines I ask the SPRDLL.DLL

tasksNamedLike: aString

| tList listSize location matchingList |

listSize := 100.

matchingList := OrderedCollection new.

tList := self new taskList: listSize.

1 to: listSize do: [ :i |

                location := (tList at: ('processName', (i printString))) indexOfSubCollection: aString startingAt: 1.

                location = 0

                                ifFalse: [matchingList add: (tList at: ('processID', (i printString))).].

].

^matchingList.

 

taskList: aSize

| tListStructure tListPointer tListFunction rc  |

tListStructure := (self taskListStructureCompoundType: aSize) newRecord.

tListPointer :=  (tListStructure abtMoveToOSMemory data).

tListFunction := PlatformFunction

                                callingConvention: 'c'

                                function: 'GetTaskList'

                                library: 'SPRDLL'

                                parameterTypes: #(pointer int32 )

                                returnType: #int32.

rc := tListFunction callWith: tListPointer  with: 100.

tListFunction := PlatformFunction

                                callingConvention: 'c'

                                function: 'GetWindowTitles'

                                library: 'SPRDLL'

                                parameterTypes: #(pointer int32 )

                                returnType: #int32.

rc := tListFunction callWith: tListPointer  with: 100.

^tListStructure.


I then look through the result for nodialog.exe.


Thanks for looking.

Seth Berman

unread,
May 17, 2019, 11:53:11 AM5/17/19
to VA Smalltalk
Greetings Steve,

Have you tried running nodialog.exe with the "-singleinstance" command line parameter?
https://www.instantiations.com/docs/91/wwhelp/wwhimpl/js/html/wwhelp.htm#href=sg/stug50.html

I believe you are on active support with us?
If this doesn't solve your issue, send in a support case as we have some things ready-to-go that
we can offer.

Kind Regards,

- Seth

Richard Sargent

unread,
May 17, 2019, 1:43:13 PM5/17/19
to VA Smalltalk
On Friday, May 17, 2019 at 8:53:11 AM UTC-7, Seth Berman wrote:
Greetings Steve,

Have you tried running nodialog.exe with the "-singleinstance" command line parameter?
https://www.instantiations.com/docs/91/wwhelp/wwhimpl/js/html/wwhelp.htm#href=sg/stug50.html

I like the idea of -singleinstance, but if my memory serves, the feedback to the user is insufficient. (Possibly no feedback at all)
I seem to recall that -singleinstance did not do anything such as raise the topmost window of the already running instance, so a minimized or obscured application would remain invisible to the user. Of course, things may have changed in the decade or two since I last experimented with that command line option.

It would be good if one could configure the image to provide message text to display if -singleinstance finds it isn't the first instance.
Of course, the implementation probably doesn't even start the VM, so getting information from the image might be problematic. Perhaps an optional argument on the command line for the message to display?


Steve, I always recommend copying nodialog.exe to e.g. myappname.exe when deploying an runtime image.
a) The task list gives better indication of what it is
b) If you were to have a second image running concurrently (i.e. a different Smalltalk application), two nodialog.exes would make the task list especially confusing and eliminate any possibility of using -singleinstance.

Seth Berman

unread,
May 17, 2019, 2:09:48 PM5/17/19
to VA Smalltalk
Hi Richard,

I don't see that there is any feedback (unless running a debug version of the the exe).

It does not start the vm, the implementation is based on the working of CreateMutex on Windows right at the beginning of main() in the exe so you would need to print to stdout.
A search on this topic shows that it is pretty much the accepted way to do it.

However, I see some other places where you can use FindWindow() to force something to the front...we just don't have that.

Looks like we have a case in our backlog on just this issue which references a google post.
The last entry in the post is interesting and worries me a little. It obviously has never rising to the level of being implementable, but I can take a second look.

- Seth

Richard Sargent

unread,
May 17, 2019, 3:12:51 PM5/17/19
to VA Smalltalk
On Fri, May 17, 2019 at 11:09 AM 'Seth Berman' via VA Smalltalk <va-sma...@googlegroups.com> wrote:
Hi Richard,

I don't see that there is any feedback (unless running a debug version of the the exe).

That's what I thought I remembered.

What about having the nodialog.exe display a message provided on the command line following the -singleinstance option (or using e.g. a -sim "message" option)?


--
You received this message because you are subscribed to a topic in the Google Groups "VA Smalltalk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/va-smalltalk/Pq5SKuLTkWQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to va-smalltalk...@googlegroups.com.
To post to this group, send email to va-sma...@googlegroups.com.
Visit this group at https://groups.google.com/group/va-smalltalk.
To view this discussion on the web visit https://groups.google.com/d/msgid/va-smalltalk/6aacb3e7-5b2e-4f54-9a4d-01ca4737d56d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Norbert Schlemmer

unread,
May 20, 2019, 8:04:48 AM5/20/19
to VA Smalltalk
Hi Steve
during the startup of the client application we are using this function call
OSSecurityAttributes>>#createMutex:lpszMutexName:
to check if the application is running. The check can be done per session (local) or per machine (global).
br
Norbert

Steve Ripley

unread,
May 20, 2019, 9:22:17 AM5/20/19
to VA Smalltalk
Thanks all for the responses!

Ripley

Seth Berman

unread,
May 20, 2019, 10:09:31 AM5/20/19
to VA Smalltalk
Hi Richard,

Sure, that's reasonable suggestion. I'll take a look.  Thanks.

- Seth
To unsubscribe from this group and all its topics, send an email to va-smalltalk+unsubscribe@googlegroups.com.

Louis LaBrunda

unread,
May 21, 2019, 9:15:24 AM5/21/19
to VA Smalltalk
Hi Guys,

I've used "-singleinstance" on windows and it works fine.  It would be nice if the image could in someway be informed that an attempt to start the same program again occurred.  If say, the program is a GUI and the main window is minimized, the image could then display the window.  This would probably get the user where they want to be.

Lou


To unsubscribe from this group and all its topics, send an email to va-sma...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages