Do an Event when the application is opened by a custom file? On C# .NET - events

The thing is, I created a file with custom information and a unique extension, let's say (.qwas). If I modified the Registry in HKEY_CLASSES_ROOT I can change its icon and choose which program will open it. What I want to do, is that when I double click it, it opens my .NET app and in the app have an event like FileOpenApp. So I can extract information from the file and do custom methods.
The kind of behavior I want to make is similar to the project files of an aplication, like the .fla of flash.
I don't know how to start with this idea, I hope anyone knows even the name of this type of procedure.
Thanks

Can't you pass the name of the file as an argument to your .Net App. Something like
[HKEY_CLASSES_ROOT\Applications[name of APP]\shell\open\command]
#="\"[path to app]\" \"%1\" %*"

Related

Is it possible to assign a custom icon to a custom file extension?

I am trying to make my own coding language and I want to have a custom file extension for it. I need to have a custom icon, and a way to check for text editors (vscode etc.). So it can run on any computer with the custom icon and and a way to check for a text editor that it will automatically open when you open the file, included. I am willing to use any coding languages as long as you help me out with it and dont just tell me what to do.
I have tried using the whole HKEY stuff and since I am using a custom file extension that is not associated with windows it doesn't show up in HKEY_CLASSES_ROOT like file extensions that are associated with windows do.
Let's say you want to have an icon associated with file extension .xyz. And your icon is resource ID #0 in Resources.dll.
These registry keys become relevant:
[HKEY_CLASSES_ROOT\.xyz]
#="XYZ"
[HKEY_CLASSES_ROOT\XYZ\DefaultIcon]
#="C:\\Path\\To\\File\\With\\Resources\\Resources.dll, 0"

Create an application and attach it on right-click on a file

I want to make an application in C# VS12 preferably, and I want to attach it on right click menu passing the filepath as an argument, it would be great if I could do that on multiple selection too. How do I make that happen?
in the installer of your application you need to add a file extension association. (for development you can test that by registering the extension manually: right click, open with...). the file name that was clicked will be passed to your app as a command line argument (those are the args[] in the main method of you app).
multiple selection is a bit trickier but certainly doable. when your app starts you need to check if you have an instance of the app already running (using a mutex for example) and send a message to that instance with the file name you received.
If you have not worked with context menu handling, you should take a look at this tutorial.
For the file path handling, you could take a look at this image editing example.

inverse of LSGetApplicationForItem

I am writing a image viewer application, which I need to set as default application for jpeg/gif files. There is an API LSGetApplicationForItem/Info for getting information on what is the default application.
But I am not able to find an API where I can set my application as the default viewer for image files.
Can you please help
You want the LSSetDefaultRoleHandlerForContentType function. Pass kUTTypeGIF for GIF, kUTTypeJPEG for JPEG.
Please only do this when the user explicitly tells you to. Otherwise, they will hate you.
There's not a public API to do that, as far as I know. Instead, you register, using Info.plist (or the Document Types section of the Info editor in Xcode), that you are a provider of viewing and/or editing for whatever file types you are interested in. This will cause the system to choose your app if there's no other app who can open those file types, and will put you in the running if the user chooses Open With from the context menu when selecting a file in the Finder.

I want to implement a File Explorer, How can I read file's icon and display them?

I want to implement a File Explorer, It is different from a normal file explorer, it first scan file system and store information into database, them read file system information from Database, and display them, I need to store the icons of the file, how can I do this? Is there any Windows APIs?
Many thanks!
SHGetFileInfo can get a handle for the icon of a file.
You need to use SHGetFileInfo. This looks like a pretty good example for .NET.

Expression Web: Shortcut doesn't point to an exe file, but I want to use it to edit

Problem: I have to support users who need to edit web pages. Some of these web pages exist only as textarea controls. Fortunately, there is a firefox plugin that allows the user to open the textarea in a default text editor. Unfortunately, this plugin requires you to point to the EXE file of the text editor you want to invoke.
This is a reasonable requirement, but ##$%^ Microsoft Expression Web is one of those applications whose shortcut .lnk file does not appear to point to a real EXE file. If there is an EXE file somewhere, it's hidden.
Question:
How can I locate the actual EXE file so people can configure Microsoft Expression web to be their editor of choice?
Update: I should have emphasized that I was looking for a way to automate this via script or batch file (hence the SO posting, in case anyone's "not-programming-related" spidey sense was tingling).
I found my executable in the following location:
C:\Program Files\Microsoft Expression\Web Designer\EXPRWD.EXE
I'm not sure if that gives you what you need, but you can always have your users (or programmatically) search for EXPRWD.EXE and go from there.

Resources