Movies knowing if called from Projector vs Director

Date:    Fri, 1 Dec 1995 06:53:05 -0500
From:    "Glenn M. Picher" <gpicher@MAINE.COM>
Subject: Re: Storing pre-generated constants/Testing for projector

Charles Wiltgen wants a movie to behave differently while authoring vs. final presentation:

>    How do I tell if I'm running from a projector, even if the
>    current movie may just be an unprotected director movie that was
>    called by the projector?
I've had some prior adventures with this topic.

Simplest Mac solution:
Use the Process XObject from the MediaBook CD to search for a process of creator MD93 and type APPL (Director) or creator PJ93 and type APPL (projector). However, this will fail if both Director and the projector ( or more than 1 projector!) are running at the same time.

Pretty simple Mac solution:
Have you ever noticed the "version" global variable that always shows up in "showglobals" listings? It even survives "clearglobals". Its value is set at startup from the 'vers' resource (ID #1) short version info string-- "4.0.4", as Director 4.0.4 ships, in both the authoring environment and in projectors.

Therefore, use ResEdit to modify that information in the projector; then you can test the global "version" to tell you if you're in the projector. Perhaps change it to "4.0.4 (runtime)".

Alternatively, to avoid the need to ResEdit the projector each time you remake it, you could copy a 'vers' #1 resource into the resource fork of your Director movie and edit that; it will be automatically copied into the projector. Or, ResEdit the 'vers' #1 info of Director itself (perhaps to "4.0.4 (authoring)". That doesn't get copied into a projector. That's probably simplest-- only 1 ResEdit ever per installed (and licensed!) copy of Director. The edited string will be displayed on Director's splash screen when starting.

Finally, you can also edit the 'vers' #1 resource in the resource files from which projectors are made-- they get copied into every projector you make. Customize "Director 4.0 68K Resources" for 68K "Standard" and fat "All models" projectors, and customize "Director 4.0 Resources" for PowerPC-only projectors. Customize them differently and you'll also be able to detect your projector type.

Be aware when testing this technique out that the Finder has a private cache of "Get Info" version information; changing the 'vers' #1 resource won't appear in the "Get Info" box for a file until you close and reopen the containing folder.

As far as I know, this has no side effects. Any code in the projector that is aware of VERS info probably checks the 16-bit version values directly, not the short info string. However, Macromedia probably wouldn't recommend this.

Complicated Mac solution (definitely no side effects):
An XObject can be written to find the creator string of the currently executing process. A Director presentation is not necessarily the foreground process, especially when "open"ing another app with "Animate in background" on or when the user switches apps. Creator strings are "PJ93" for a projector and "MD93" for Director itself. I've done this; it works. This solves the ambiguity of the simplest solution above, because it doesn't matter if both Director and the projector are running-- you're testing only for the app that your Lingo is running in.

Simple Windows solution
Use the TASKMGR.DLL from the MediaBook CD to get a list of all running programs. If that string contains "Director 4.0", you're probably in Director; if it contains the name of your projector (without the .EXE suffix), you're probably in the projector. This technique fails if you're running Director and the projector at the same time. It also fails if you assume that Director is in line 1 of the returned string-- Director might be animating in the background, and line 1 is empty under Windows 95 (I dunno why it's different).

Complicated Windows solution
The "version" global variable is drawn from DIRECTOR.RSR while authoring and in a projector from the bundled PROJECTR.RSR . You can't change them with a resource editor like Visual C++'s AppStudio-- you must use a hex editor, or, believe it or not, Windows "Write", as long as you click "Don't convert" when opening a binary file (use the version that ships with Win3.1 and WfW3.11, not Win95).

Open those files and search for the first instance of "4.0.4" (there are several). Very carefully replace that first "4.0.4" with exactly five other characters-- perhaps "(dir)" for DIRECTOR.RSR and "(prj)" for PROJECTR.RSR. Save. Remake any projectors. Now you should be able to detect the difference using the "version" global variable.

This may have other side effects, but not as far as I can tell. It's certainly not recommended by Macromedia. I hope they can provide a better solution at some point.

Lingo cross-platform solution:
Edit the 'vers' #1 resource to "(prj)" in the projector and "(dir)" in Director on the Mac as descrbed in the "Pretty simple mac solution" above; use the "Complicated Windows solution" above to do the equivalent on Windows. Then your Lingo will work the same on both platforms.