Ever wondered what the maximum length of a command line param to a .NET application is?

I am investigating simple integration options between processes and wanted to know the limitation of this method of passing info from one process to another.

I found some documentation on MSDN (http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx) which states that the max commandline param could be 32,768 characters.

So then I put together this .NET app to test that:

Screenshot of resulting two applications running

You can specify the length of data that you want passed to the other process.

The code that launches the other process looks like this:

And then I modified the other application’s Program.cs file as follows:

Changes to the other process's program.cs file

The result of this test?

I can pass 32,673 characters to the other process. Which is 5 fewer characters than the API call allows. (4 if you subtract the null terminator on the string).

Does anyone know where the additional 4 characters have gone?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s