How do file extensions work? - windows

I did a quick Google search of "how do Windows extensions work," but it only came up with how to change file extensions.
I was making my own file extension for an image compressor, and as of now you'd have to load the text file into a program and its processed, but in a real-world environment that's not something you want to make people use.
I'm not saying I want to build the next best image compressor but it'd be useful to understand how file extensions work.
I understand a file had content, and the content is defined for use by the extension, but when you execute a file (double click) what happens?
If I click a .x file (example), would there be a bind that has to be done in a system/environment level, to say point to a batch file that runs everything else?
Thanks in advance!

Related

Add startup options to a file (Windows)

Is it possible to add startup options directly to the exe instead of a link file?
F. e. You have the command "-minimized". Now you can just add this to the shortcut file and the program will start minimized.
Is there a way to do this to the exe file directly? (Hex Editor?)
Thanks in advance
In order to physically change an executable file it would need to be modified from source code and recompiled. I don't recommend changing anything in an executable file using a Hex Editor unless you are an expert and know what you are doing to reverse engineer an application.
I would suggest that you simply create a shortcut and modify that to minimize / maximize the application on open as you mentioned. That way you won't risk completely corrupting the executable.

Changing default program for a file type (workaround)

I would like to specify that images of a certain type (for example, .png) open by default in a program I've written when the file is contained in a certain directory. I've seen by searching (Change Default Program for a specific folder) that this is not possible on Windows 7 or 8.
I am saving these images in this directory myself, so I have some leeway with how I name the files. For example, I could change the filename a bit... perhaps to be example.myprog.png or something similar. Is there a way to set it up so files that match this filename pattern get opened, while other .pngs (in other directories) still open in the default viewer?
I don't really want to name these PNG images example.myprog (i.e., fully change the extension), because when the user is browsing the directory in Windows Explorer, I would like the thumbnail images to still show up. Also, users will be eventually transferring these images to their own machines, where they'll want to use standard image viewers to look at them.
If this is not possible, does anyone have another suggestion for how to tackle this problem?
As you are mentioning that files should be opened in a program that you have written, try to change the code of your program to read files from the specific folder. So, by opening your program from anywhere in your pc, you should be able to open files from specified folder.

How to close a PDF file using Ruby?

I have been working on Vanilla, a LaTex preprocessor. I and most people open their PDF files to see how their output looks like. But sometimes, we forget to close it down before starting the compiling process again. If the PDF file is open, then the LaTex compiler complains that it cannot write to that file. So I want to add code to the preprocessor which will look if the output PDF file is open and it will close the PDF file if it is open. I have been looking everywhere to see how to go about doing it. I am not an expert in Ruby. I don't want to kill the whole process of Acrobat32.exe or any other PDF viewing program used to view that file because the user might have other PDFs open in the same program. I just need a way to kill the process of that one PDF file. So can anyone suggest me a way to do it?
Can't you just move the old file first, remove it if possible, and then generate a new version of the same PDF with the name you want?

Redirect default program to another program when a file opens in Windows OS

This is only under windows env.
As I know windows os identifies associated application of a particular file by file extension.
Like wise each file (binary) starting with corresponding symbols ("starting symbols"). For an example .JPG starts with ÿØÿà. Let say I open this .JPG file in a Hex editor or a Text editor and then I change that starting symbols into another file type. for an example I can change ÿØÿà to .Eߣ (.mkv). So when I double click on the .JPG the Windows Photo Viewer says there are some errors or similar message. So I need to get some information about the application that tries to open that kind of a file. If I can, I need to open that file using the application that associated with "starting symbols".
Briefly when I open .JPG I need to open a default video player .mkv files. But It may not work for this example. Because I changed only the "starting symbols" of my .JPG.
Please give me any idea to do this.
Thanks!
When you encrypt the file, give it a new extension. e.g. Picture.jpg becomes Picture.encrypted-jpg. You then register as the handler for encrypted-jpg, decrypt the file, then launch the normal jpg handler.
When the shell is asked to perform a verb on a file, the shell does not use the contents of the file to determine which app to pass it to. The file extension is what determines how the file will be treated.
You wish to use the contents of the file to influence which app processes a shell verb. In order to do so you would need to create a launcher app that reads the file header and then decides which app to pass the file on to. You would assign your launcher app as the handler app for all file extensions that you were interested in.
Although you could do this, it would be much easier just to set the file extension appropriately.
The proper way to do this sort of thing is to replace the files with reparse points.
The downside is that this involves writing a file system filter driver, i.e., an operating system extension, which is a whole level of trouble above and beyond ordinary application programming. (Since Windows already does file encryption, I doubt it would be worth the effort.)

Writing a simple app to convert files to pdf

I want to create an application on a Mac to convert multiple files (txt, pdf, doc, html, etc) to a single pdf file that can be printed. The real point is that if you have 50 texts you don't have to open every single file and click command-p.
I'm not quite sure whether the best way to do this is by creating a full-fledged app or an automator plugin (or something else). If I remember correctly there's a filter in mac os's terminal that can convert files to pdf (but I forgot what it's called).
So would an automator plugin do this well, or shall I make an app for this? Can you provide me advantages for each answer?
I've done cocoa touch programming before so I can write objective-c quite well.
Use appscript, either as an action in an automator script or standalone. The advantage is that it is very simple and will take you a fraction of the time to write an app.
Here is something very close to what you want. It sets up a drop-folder and each file dragged onto it is printed (you can use multiple-select to get what you want). It uses Apple Works 6 which doesn't support the file-types that you want.
To modify it to use the Preview application instead you need to change the tell command in the script and then google the dictionary for Preview to check which verb to use for printing.

Resources