The file name is passed on the command-line. For instance, in Windows, you specify the command to run when opening a file (located in the registry).
This is an example using my mapping for a Visual Studio .sln file. It will run:
"C:\Program Files\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe" "%1"
The '%1' gets replaced with the file that the user opened.