Forums > Dev

Quick q: code to recognize standalone?

Jun 15 2011 | 2:13 pm

Could use some ideas on how to detect if the external is built into a standalone application.


Jun 15 2011 | 5:02 pm

I’m not clear on what you are asking? Do want to know….
1. if a specific external was added to the collective during the standalone building process?
2. if your patch is being run in a standalone/runtime or in Max 5?

1. The Max window prints out all the files added to the standalone when it makes it.
In the file menu, you can use the "List externals and Subpatcher Files" command to print everything in the Max window.
You can use the message "collectfiles" to thispatcher in your main patch – this can be useful.
You can startup your standalone and see if there’s an error in the Max window! Note all the problems, and create a shell script, .bat file, or automator to gather all these problematic missing files for your standalone and put them in the right place.

for 2. :

-- Pasted Max Patch, click to expand. --

Jun 15 2011 | 5:10 pm

That’s weird, part of my post went missing… :(

What I’m looking for is a line or two of code in C I can include in my external that tests, on startup, whether the external is being included in an application/collective? Basically it would be if it’s being run in a standalone, look for a support folder in a different place.

Sorry this wasn’t clear but I’m not sure why part of my post wasn’t included in the above.

Jun 15 2011 | 5:35 pm

Please, check out this thread:

– Luigi

Jun 16 2011 | 2:56 am

Wonderful! Thanks so much, Luigi!

Jun 21 2011 | 6:12 pm

Here is the code I use for this in Tap.Tools :

// Check for Environment (Max or Standalone)
		char	appname[256];
		int		isMax = 0;
		appname[0] = '';

		#ifdef MAC_VERSION
			CFBundleRef	bun = CFBundleGetMainBundle();
			CFURLRef	url = CFBundleCopyBundleURL(bun);
			CFStringRef string = CFURLCopyLastPathComponent(url);
			CFStringGetCString(string, appname, 256, 0);
			isMax =	strcmp(appname, "");
			char	*appname_win;
			HMODULE hMod;
			hMod = GetModuleHandle(NULL);
			GetModuleFileName(hMod, (LPCH)appname, sizeof(appname));

			appname_win = strrchr(appname, '\');
			isMax =	strcmp(appname_win+1, "max.exe");	// Max 4 had a lower case first letter
			if(isMax)	// the above did not match
				isMax =	strcmp(appname_win+1, "Max.exe");	// Max 5 has an upper case first letter
			//post("TT IsMax: %i AppName: %s", isMax, appname_win+1);
		is_standalone = (isMax != 0);
Jul 18 2011 | 2:03 pm

Tim: Thanks so much!

Viewing 7 posts - 1 through 7 (of 7 total)

Forums > Dev