CR4® - The Engineer's Place for News and Discussion®


Previous in Forum: Image Processing Software with Line-Thinning Feature   Next in Forum: 500 Internal Server Error
Close
Close
Close
10 comments
Associate

Join Date: Mar 2009
Location: USA
Posts: 32
Good Answers: 3

Creating An Extension Based Context Menu Item In Windows

01/23/2017 4:26 PM

I am attempting to write a batch file that will allow me to open PDF files in my exe through the right click context menu in Windows. I have it working perfectly when I put the registry keys in the HKEY_CLASSES_ROOT\*\shell but this does not discriminate file types. I am looking to have my menu item only come up when right clicking PDF files and google only ever seems to show how to add a menu item for all files.
Here is what I have that does work:

HKEY_CLASSES_ROOT\*\shell

Send to example (Default) REG_SZ (value not set)

command (Default) REG_SZ "c:\users\puddin\appdata\roaming\example\example.exe "%1""

However as stated above this shows for any file and not just PDF's. How do I go about making a context menu for a particular file type? I've tried looking at programs such as 7-zip and notepad++ that I currently have installed for reference but I just cannot make heads or tails of it.

__________________
Those who are afraid of the dark has never seen what the light can do.
Register to Reply
Pathfinder Tags: click context menu reg Registry right
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Comments rated to be Good Answers:

These comments received enough positive ratings to make them "good answers".

Comments rated to be "almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, rate them!
Guru

Join Date: Mar 2007
Location: at the beach in Florida
Posts: 19296
Good Answers: 1129
#1

Re: Creating an extension based context menu item in Windows

01/23/2017 5:47 PM

Why not just get a mouse with programmable buttons...?

__________________
Life is like riding a bicycle. To keep your balance you must keep moving. A.E.
Register to Reply Score 1 for Off Topic
3
Associate

Join Date: Mar 2009
Location: USA
Posts: 32
Good Answers: 3
#2

Re: Creating an extension based context menu item in Windows

01/23/2017 6:00 PM

Not sure if you are just trolling this one or what. Having another physical button has nothing to do with adding to the shell menu. Sure you can map a button to run anything but the end results are very different from a right click. You cannot rely on users to have special buttons.

__________________
Those who are afraid of the dark has never seen what the light can do.
Register to Reply Good Answer (Score 3)
Guru

Join Date: Mar 2007
Location: at the beach in Florida
Posts: 19296
Good Answers: 1129
#3
In reply to #2

Re: Creating an extension based context menu item in Windows

01/23/2017 6:43 PM

You want us to help you write code for Windows and you're not sure who's trolling whom?

__________________
Life is like riding a bicycle. To keep your balance you must keep moving. A.E.
Register to Reply Score 2 for Off Topic
Associate

Join Date: Mar 2009
Location: USA
Posts: 32
Good Answers: 3
#4

Re: Creating an extension based context menu item in Windows

01/23/2017 7:04 PM

If you can consider a batch file as "code" then sure I am looking for ideas and guidance as to how I should proceed on what I have established to work. Asking for help isn't really considered trolling but in the most obscene of circumstances.

__________________
Those who are afraid of the dark has never seen what the light can do.
Register to Reply Score 1 for Good Answer
Guru

Join Date: Mar 2012
Location: Out of your mind! Not in sight!
Posts: 4013
Good Answers: 92
#5

Re: Creating an extension based context menu item in Windows

01/23/2017 8:10 PM

Jack I have no idea but some observations:

if REG_SZ obtains a value what does it stand for? can yiou add a "*.pdf"

same goes for after example.exe "%1" could you add a "/*.pdf"?

There ya go I have no idea. The only other option is probably to add another registry key with a file nominator.

Good luck!

__________________
Common Sense Dictates
Register to Reply
2
Guru

Join Date: Jul 2012
Location: Madison, WI.
Posts: 1036
Good Answers: 45
#7
In reply to #5

Re: Creating an extension based context menu item in Windows

01/24/2017 9:58 AM

Some folks here really hate Windows.

__________________
Knowing is the end result of learning, not believing.
Register to Reply Good Answer (Score 2)
Guru
Safety - Hazmat - New Member United States - US - Statue of Liberty - New Member Engineering Fields - Chemical Engineering - Old Hand

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 13569
Good Answers: 155
#10
In reply to #7

Re: Creating an extension based context menu item in Windows

01/24/2017 3:31 PM

Jack: Pretty much, whatever you tell it to do, Windoze 10 will take the reverse action, delete the file you were looking for and get rid of all desktop icons you have not used within the last 10 milliseconds.

Then it starts changing the background screen color, until everything is invisible except stuff that is pink or purple.

__________________
If it ain't broke, don't fix it. Just build a better one.
Register to Reply
Guru
Popular Science - Biology - New Member Hobbies - Musician - New Member APIX Pilot Plant Design Project - Member - New Member Hobbies - CNC - New Member Fans of Old Computers - ZX-81 - New Member

Join Date: Jan 2007
Location: Centurion, South Africa
Posts: 3918
Good Answers: 97
#6

Re: Creating an extension based context menu item in Windows

01/24/2017 3:29 AM

You can create a case statement by using the command IF

I cannot remember the syntax any more but you can

send pdf files to Acrobat and doc files to Word etc etc

in words

IF name contain .pdf do acrobat name

IF name contain .doc do word name

__________________
Never do today what you can put of until tomorrow - Student motto
Register to Reply
Associate

Join Date: Mar 2009
Location: USA
Posts: 32
Good Answers: 3
#8

Re: Creating An Extension Based Context Menu Item In Windows

01/24/2017 10:31 AM

So I made a bit of progress on how it is done but not for the file type I want. I can easily discriminate file types for the context menu for other files such as .jpeg or .txt The issue lies in having it show up for .pdf
Here is what shows up when looking under the .jpeg reg key.

HKEY_CLASSES_ROOT\.jpeg (Default) REG_SZ jpegfile

So I head on over to the key by the name of jpegfile under the same root class

HKEY_CLASSES_ROOT\jpegfile\shell

And then I add a couple keys

HKEY_CLASSES_ROOT\jpegfile\shell\Send to Example

HKEY_CLASSES_ROOT\jpegfile\shell\Send to Example\command (Default) REG_SZ "c:\users\puddin\appdata\roaming\example\example.exe "%1""

This works perfectly and the menu only shows up for .jpeg files. However when I try to use the same procedure with a .pdf it simply doesn't work. When I look at the reg key in root for the .pdf here is what I get:

HKEY_CLASSES_ROOT\.pdf (Default) REG_SZ pdf_auto_open

So I head on over to the pdf_auto_open key and add the same keys to the shell

HKEY_CLASSES_ROOT\pdf_auto_file\shell

HKEY_CLASSES_ROOT\pdf_auto_file\shell\Send to Example

HKEY_CLASSES_ROOT\pdf_auto_file\shell\Send to Example\command (Default) REG_SZ "c:\users\puddin\appdata\roaming\example\example.exe "%1""

And when this is done exactly the same way nothing at all shows up. I am thinking it has something to do with the fact that it says pdf_auto_file rather than something like pdffile but I am unsure about that.

__________________
Those who are afraid of the dark has never seen what the light can do.
Register to Reply Score 1 for Good Answer
Guru

Join Date: Jul 2012
Location: Madison, WI.
Posts: 1036
Good Answers: 45
#9
In reply to #8

Re: Creating An Extension Based Context Menu Item In Windows

01/24/2017 10:59 AM

I think you might be right since PDF files were rom the outset a stand alone cross platform file type that required a special, stand alone program (Adobe) to open. You might want to look at the key for the Adobe exe and see how that file is designated. Just a thought.

__________________
Knowing is the end result of learning, not believing.
Register to Reply
Register to Reply 10 comments
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Comments rated to be Good Answers:

These comments received enough positive ratings to make them "good answers".

Comments rated to be "almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, rate them!
Copy to Clipboard

Users who posted comments:

Hendrik (1); IdeaSmith (1); Jack Puddin (3); James Stewart (1); rashavarek (2); SolarEagle (2)

Previous in Forum: Image Processing Software with Line-Thinning Feature   Next in Forum: 500 Internal Server Error

Advertisement