Windows explorer get list of selected items and pass it to another process - windows

I have to create File/Folder management system. In which user can select multiple files/folder and from context menu execute an command.
That command sends list of all selected files/folders list to invoke a process. So that, process can work on file/folder list.
If process is running the context menu should not shown or greyed out.
I added context menu but can't find the way to disable it. How can I do all this?
Any possible study link will help a lot?

Your IContextMenu::QueryContextMenu handler can apply whatever logic you desire to determine whether to show/hide a menu item, and if shown, whether it is enabled or disabled. Note, however, that in general, shell extensions should not be written in managed code due to CLR injection concerns.

Related

How to disable cut, copy, paste, rename, etc from the Windows Registry?

I'm trying to create a software in VB.Net as my uni project to disable the following from a Windows 7 pc. I think they have to be disabled from the context menu of the Windows Registry, but instead of disabling the whole context menu, I'd like to disable the following individually.
Cut, copy, paste, rename, delete, open, print, share, create shortcut, open with, send to, new, properties.
I want to give users the option of disabling them selectively/individually via checkboxes so those options will be disabled in the right-click of a mouse.
My problem is I don't know which is the right key to disable as the registry is so huge & some keys are similiarly named.
Could anyone help me to say what are the exact key locations of the above-mentioned right-click functions in the Windows Registry or how to go about this ?
The deep flaw in the assumptions made in this question is that the context menu is configured by registry entries. It is not. Windows allows modifying a window's context menu by sending the WM_CONTEXTMENU message. Code, not config. If you are not happy with the default implementation of that message then you subclass the window procedure and provide your own message handler for that message so you can display your own context menu. This is core to the way Windows works.
Modifying the context menu of a program you didn't write is possible too but much more complicated. You use SetWindowsHookEx() to inject a DLL into the other process. You cannot write a DLL like that in VB.NET, it requires native code. Because that process won't have the CLR loaded to run your managed code.

Is there an API in Windows 7 for creating "split menu items"?

I don't know what their official name is, but I mean these things:
Is there an official API for creating those in my own program?
And related question: Did you ever see these "split menu items" used anywhere other than the start menu? Where? This could point at an API.
Glancing at my own start menu, I'm guessing that most are generated the same way "Recent Documents" used to be done. i.e., observing the files that programs open.
As for new APIs, this page might be a good place to start sniffing around: http://msdn.microsoft.com/en-us/library/ee461765%28VS.85%29.aspx
To create tasks like internet explorer etc, use ICustomDestinationList->AddUserTasks(), the recent items should show up for file types you are registered to handle (They are added by the open/save dialog or manually by calling SHAddToRecentDocs())

WinAPI: Call context menu entry provided by shell extension

The software Dropbox provides an shell extension which adds context menu items to all files in a specific folder. One of these generates a public link to view the selected file.
In a C# tool I want to call this entry without any user interaction. I want to achieve the same behavior as if the user clicked on the context menu item of a selected file.
I know that the shell extension is provided by a DLL, is it possible to make a call to this DLL to achieve the expected behavior?
Shell extensions implement IContextMenu and it is possible to execute menu commands without showing a menu (See this blog post for details about "hosting" IContextMenu)
Once you have the menu, you would call IContextMenu::GetCommandString and look for a specific verb, if Dropbox does not have a somewhat unique verb, you are going to have to do something hacky, either match by menu text alone, or call the Dropbox shell extension dll directly (DllGetClassObject export) and fake everything (Pretend to be COM and shell) or if you know the CLSID, you can at least get help from COM and just do the shell part.
There is a freeware tool called runmenu that allows you to play with shell menus/IContextMenu (I'm sure you can find a copy somewhere)

Application started by user or another application?

This is a very general question:
I was wondering whether it is possible to find out whether an application (any kind of application no matter if it a delphi-application or java or whatever) was started by a user or by another application? And if it is possible and I see that an application was called by another one, can I find out what the "father" application is, that called the new programm?
Thnx in advance!
EDIT: Maybe it is too general - How can I see whether a Delphi application has a parent application with Delphi itself, e.g. one application was started by a service and I need to find that service?
Every single running application has a parent application, which launched it (except for root system process).
It is not possible to tell, whenever it is user who directly clicked on application to lauch it or not.
Example: take Explorer shell (not Internet Explorer).
You can double click on any application to launch it. The parent process will be explorer.exe.
You can right-click on any file and a bunch of context menu extenders will load. Some of them may launch external applications to, say, create a preview of video-file (I saw this, swear!). The parent process will be explorer.exe, but user didn't indended to lauch any application. He just wants to view file's properties. He didn't even know, that applications were lauched!
Example: take Total Commander or any other two-panel file managers, which supports plugins for archives.
You can double click on any
application to launch it. The parent
process will be totalcmd.exe.
You may enter archive file and copy
(extract) few files from it to your
Documents folders. Corresponding
plugin may handle extraction by
itself or run invisible process to
handle all work. All you see is
progress bar in Total Commander. But
there is a new proces and its parent
is totalcmd.exe again.
There are no differences between cases 1 and 2 in both examples.
BTW, the definition "started by user" is unclear. You even may say that nothing can happen without user's command. All those background processes in cases #2 were launched because user asked for it. Well, user didn't asked for lauch explicitly, but he asked for operation itself.
You don't mention if you want to do this programmatically or if you're looking for a tool to just show the information.
If you just want to view the information, you can use Process Monitor, part of SysInternals:
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
In the Tools menu, there is a 'Process Tree' view that shows you a tree with parent / child process relationships and as well as the owner of each process.
If you want even more detail about processes, look at Process Explorer:
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
if it started by the user from windows so the parent will be explorer.exe, otherwise the parent will be the application which run the process.
to check the parent of a process by using tool check Ander Miller reply.
Did you see this question?
I'm not sure that I see problem right now.

How do I add items to all windows' window menus?

I'd like to write a utility in the vein of PowerMenu - it adds some extra stuff into all applications' window menus (alt-space, that menu).
How does one go about doing this?
Inject some code to each window's process.
Use GetSystemMenu() in the hook to retrieve that windows "alt-space" menu
Make your modifications
Cleanup
I'd personally use SetWindowsHookEx(), WH_CALLWNDPROC, and a CallWndProc to achieve step 1, requiring a call to UnhookWindowsHookEx() in step 4, and bit of custom message pumping to get step 2 rolling. That's just personal preference though.
You can do it in such a way:
Get all the windows that have a system menu
Insert custom items into the menu
Install hooks that will send events from menu items to your process
Handle events inside your process
You can find an example here https://github.com/AlexanderPro/SmartSystemMenu

Resources