Click to See Complete Forum and Search --> : shell extension: context menu extension
Trasgu
December 26th, 2004, 11:51 AM
I would like my aplication had something like a context menu extension, but the samples I found were to Visual-C++, so I need some help. I want to get only the path of the selected files. The question is:
Is there a way to get this in C++?.
NoHero
December 26th, 2004, 11:58 AM
Plain ANSI C++ won't help you registering such an extension. You will need at least the advapi function to access the registry. How to register such an extension has already been posted here (http://www.codeguru.com/forum/showthread.php?t=322940). A nice way to get the path of the selected file is just to trim of the filename.
How to trim of the filename:
char *file = "C:\\some\\folders\\anexe.exe";
char *ptr = strrchr(file, '\\');
if ( ptr != NULL )
{
ptr[1] = '\0';
}
Trasgu
December 27th, 2004, 11:13 AM
It works well when I open one archive with my application, but if I have an indeterminate number of selected archives how to do to my application get the archiveīs paths and the application be opened only one time.
NoHero
December 27th, 2004, 12:02 PM
If you want to do so, I think you need a DDE server, and have to specify the name of the DDE server in the registry. For example Dev-C++ does for handling more than one .cpp file:
HKEY_CLASSES_ROOT ->
-> .cpp
----> DevCpp.cpp
-> DevCpp.cpp
----> Shell
------> Open
--------> Command [ C:\programme\dev-cpp\devcpp.exe "%1" ]
--------> ddeexec [ Open("%1") ]
-----------> Application [ DEVCPP ]
-----------> topic [ DevCppDDEServer ]
Default values of the keys are in []. I haven't read through DDE yet, but if you have a clue what a DDE server is you might catch a clue from the keys above. Let me know if you found a solution and if I should look deeper into this.
Best Regards
Trasgu
December 30th, 2004, 11:37 AM
I found about DDE an introduction (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/dynamicdataexchange/aboutdynamicdataexchange.asp) and examples (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/dynamicdataexchange/usingdynamicdataexchange.asp), but at the moment I only get initiating several conversations with all opened server applications without to know what is the correct windowsīs explorer; and I donīt get the application be opened only one time with the ddeexec key.
wake
January 1st, 2005, 05:21 AM
If you're looking to create a DLL based context menu extension that can operate on multiple files at once, then you will need to use ATL (I don't remember if a simple exe/registry entry can handle multiple files or not at the moment.)
Mike Dunn has several articles on this topic over at Code Project, the first of which is here: http://codeproject.com/shell/shellextguide1.asp
Trasgu
January 1st, 2005, 06:57 AM
Mike Dunn has several articles on this topic over at Code Project, the first of which is here: http://codeproject.com/shell/shellextguide1.asp
Thank you by the link, but I really had read the article and donīt help me too much because Iīm programing with Dev-C++.
Trasgu
January 2nd, 2005, 12:05 PM
I get a good conexion DDE, my error was to think that my application was the client when it was the server. Now I try get the data in a string, but the compiler give me some errors:
Proyecto1.cpp:34: no match for `DDEPOKE& = DDEPOKE*' operator
C:/Dev-Cpp/include/dde.h:35: candidates are: DDEPOKE& DDEPOKE :: operator=(const DDEPOKE&)
Proyecto1.cpp:40: invalid conversion from `BYTE*' to `const char*'
in this code:
DDEPOKE lpPokeData;
PUINT_PTR hData;
char buf[MAX_PATH+1];
//...
if(!(lpPokeData=(DDEPOKE *)GlobalLock(hData)))
//...
strcpy(buf,lpPokeData.Value);
I donīt understand why the DDEPOKE structure get the data in BYTE Value[1]; when it must get strings more longers than a Byte.
NoHero
January 2nd, 2005, 12:36 PM
The DDEPOKE& is not a pointer to this object but a reference. Do not mix up pointer and reference.
strcpy((char*)buf, (const char*)&lpPokeData.Value[0]);
Should also fix your problem.
Trasgu
January 8th, 2005, 05:28 AM
Somebody knows how to get a string when only you have the direction of the first byte as type BYTE?.
A solution is using this:
StringCchCopy(szItemValue, *pcch +1, lpPokeData->Value);
where szItemValue is char, *pcch is size_t, and Value is BYTE,
but the StringCchCopy need the strsafe.h that I havenīt.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.