[racket] multiple instances of compiled for distribution software
At Mon, 20 May 2013 16:48:50 -0800, Zelah Hutchinson wrote:
> So I think I have a handle on how to run multiple instances of a
> compiled program under Mac OS. I should be able to catch the
> command-n keyboard input in my compiled application. But I run into a
> similar problem when I work in Windows OS. I compile my source code
> for distribution. When I double click the application icon for a
> second time, I still only get one instance of the program. This seems
> like unusual behavior under Windows. What should I do here to obtain
> multiple instances?
It does seem like it has become unusual behavior under Windows. I think
it was common back when we made that choice, but it's also possible
that I was confused back then.
Single-instance mode can be disabled in an executable, but I see that
the configuration is currently only available at the level of the
`create-embedding-executable' function. I'll add a more accessible
point of configuration.
Meanwhile, you could manually edit the binary to change its mode. The
string "yes, please check for another" is embedded in the generated
".exe" file. If you change that leading "y" to "n" (I know that sounds
crazy), then single-instance mode is disabled.
Below is a Racket program that will change an executable for you.
----------------------------------------
#lang racket/gui
(define exe-file (get-file))
(define-values (i o)
(open-input-output-file exe-file #:exists 'update))
(define m (regexp-match-positions
#rx#"yes, please check for another"
i))
(unless m
(error "not a single-instance Racket-generate GUI executable"))
(close-input-port i)
(file-position o (caar m))
(write-byte (char->integer #\n) o)
(close-output-port o)