|
Add a key to HKEY_CLASSES_ROOT\exefile\shell. Under that key, add another key that will show up in the context menu (e.g., Process). Under that key, add a key named command. Change the (Default) value for the command key to the path\name of your application. If your application will require the name of the file that was clicked on, which it most likely will, supply %1 in double quotes.
So if I wanted Process to show up when I right-click an exe file, my registry key would look like:
HKEY_CLASSES_ROOT\exefile\shell\Process\command
For demo purposes, the value for (Default) was calc.exe. Now when I right-click a file and select Process from the context menu, the Windows calculator comes up!
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks for your tip now it works!
But why the value for command always has to come with %1
if you select a number of files what you get is the first file
in argument, right? Is there any switch/option to send all the
parameters to exe?
Thank
|
|
|
|
|
skoizumi29110 wrote:
Is there any switch/option to send all the
parameters to exe?
I believe it is %*.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
unfortunately,
I can't pass to any value with %* option
|
|
|
|
|
skoizumi29110 wrote:
I can't pass to any value with %* option
What exactly does this mean?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hello. I am trying to make a program that sets a system whide CBT hook withouth the use of
a dll that is attached to all the processes.I am using tyhe CreateThred function to
achieve this.I have already made a program that sets a system whide Keyboard hook and it
works so I know that this method has potential.
I do like this:
this is the main function:
[code]
WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
int c;
MSG msg;
Module = GetModuleHandle(NULL);
CBTlogfile="e:\\zama.txt";
DWORD CBTTID=0;
/* Already installed CBT we have */
if (dejaCBT)
{
MessageBox(GetDesktopWindow(),"CBT deja pornit","oaleao",MB_OK);
}
/* Create thread */
CBTCapThread = CreateThread(NULL,0, CBTThread,NULL, 0, &CBTTID);
if(CBTCapThread == NULL)
{
MessageBox(GetDesktopWindow(),"nu se poate sa se porneasca
CBTul","oaleao",MB_OK);
}
do
{
GetMessage(&msg,0,0,0);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
while((msg.message!=WM_QUIT||msg.message!=WM_DESTROY||msg.message!=WM_CLOSE)!=0);
}
[/code]
This is my thread function:
[code]
DWORD WINAPI CBTThread(LPVOID param)
{
MSG msg;
int i;
/* We are now recieving from CBT*/
dejaCBT = 1;
MessageBox(GetDesktopWindow(),"am ajuns shi aici","sunt ciumeg",MB_OK);
/* Make sure we have a writable file ready */
fd = _open(keylogfile, _O_WRONLY|_O_CREAT|_O_EXCL, _S_IWRITE);
_close(fd);
/* Open the file again for appending */
if ((fd = _open(keylogfile, _O_WRONLY|_O_APPEND)) == -1)
{
MessageBox(GetDesktopWindow(),"nu pot sa deschid fishieru pt
append","oaleao",MB_OK);
return (1);
}
CBT = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc, Module, 0);
/* Loop forever and read from CBT */
while (Logging) {
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
GetMessage(&msg,NULL,0,0);
DispatchMessage(&msg);
}
Sleep(1);
}
UnhookWindowsHookEx(CBT);
CBTCapThread = NULL;
_close(fd);
return (0);
}
[/code]
and this is my hook function:
[code]
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam)
{
if(code==HCBT_ACTIVATE)
{
//at the time there is nothing written here and still it doesn't work
//whatever I write here results are the same so let's just say this does nothing
}
return CallNextHookEx(CBT, code, wParam, lParam);
}
[/code]
Now, this program compiles and links flawlessly but when I run it it shut's down the
program it is first run in, for exemple windows explorer or Visual Studio and then it
doesn't do anything. it just sits there.
Please help. Also if you have a better way of doing this I am open to suggestions.
|
|
|
|
|
Is the thread created successfully?
What is the return value from SetWindowsHookEx() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Also, you use C runtime library calls in your thread.
If should carefully examine notes about CreateThread versus beginthreadex, you would observe the warning that you should use beginthreadex instead of Createthread to start your threads if you use the C runtime library calls, less you run into init errors and memory leaks.
|
|
|
|
|
|
if all global hook functions must be in a dll how come my keyboard hook works?
SetWindowsHookEx works because I put MessageBox(bla bal bal) inside the CBT hook proc and I got lots of message boxes so I'm guessing it works, I dodn't check what it returns, however the program still crashes the program it is being run from, like explorer and visual studio).
|
|
|
|
|
Hello everyone!
I have an MDI application (using VC++ 6), which utilizes several document templates as well as just dialogs. Recently I started adding the context help feature (just control-related popup windows and the "?" button functionality). It works fine for simple dialogs, but how to add the same to a CView? I have CTreeView-based CView and would like to have the same "?" button there too in order to preserve the UI consistency...
Thank you for help in advance
Mike
Mike
|
|
|
|
|
Hi guys, i'm a final year computer engineering student currently developing a software to extract messages from instant messengers as part of my final year project.
I would need some opinions on the architecture i had researched on. Currently i proposed the popular method of getting the handle of the message window once it is activated retrieve the text from the messagebox. This method is widely implemented i believe, for its simplicity and straightforward programming. My supervisor in charge however commented that this is not very stable as it is too dependent on the application itself. He said a solution that will be less dependent will be better.
I believe another way will be to go into the lower level instead of the application level, such as WinSock, to retrieve the message. However i think this might be too complex and at the end of the day, not that feasible.
Does anyone has any opinions that can help me? Personally i think the first method is still the better one. I would really appreciate anybody who can comment on this such as the pros and cons or even if the 2nd method is viable. Thank you all in advance .
|
|
|
|
|
peachieboy wrote:
Currently i proposed the popular method of getting the handle of the message window once it is activated retrieve the text from the messagebox. This method is widely implemented i believe, for its simplicity and straightforward programming. My supervisor in charge however commented that this is not very stable as it is too dependent on the application itself. He said a solution that will be less dependent will be better.
Agreed. If the window caption or class changed, your method of finding the window would cease to function.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Have you looking into other instant messangers? there are some libraries that you could use that might fill your needs. Look up GAIM, and koPete, and ask the developers.
Those are two instant messangers for unix that come to mind, not saying they are any good. If nothing else you can read their source, and leverage that into the backend for your project. I think they both use some common libraries to do the task.
The above is a suggestion. I'm not clear on exactly what your goal is. It might be useless.
|
|
|
|
|
If I created a class inwhich I grabbed some registry settings and moved them to a memory variable in my class. What is the best way to pass these settings back to the calling main app?
And will the destructor destroy and memory variables when it leaves that class to go back to the calling app?
One last question. How come if I return a pointer to a memory variable, back to the calling app, the destructor does not destroy that. Does this mean that that data will reside in memory until the main app is exited?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
What is the best way to pass these settings back to the calling main app?
Does the "main app" own an instance of the class?
Tom Wright wrote:
And will the destructor destroy and memory variables when it leaves that class to go back to the calling app?
The destructor will be called when the object goes out of scope, or when delete is called on the object.
Tom Wright wrote:
How come if I return a pointer to a memory variable, back to the calling app, the destructor does not destroy that.
We'd be in a world of hurt if passing pointers caused destructors to be called.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
DavidCrow wrote:
Does the "main app" own an instance of the class?
Yes...ah...What do you mean? This class is a generic class that has no base class to it. It is part of my main app.
DavidCrow wrote:
The destructor will be called when the object goes out of scope, or when delete is called on the object.
Okay. I understand that. So if the class has never been destroyed by my call app...by using the delete function (or goes out of scope)then any data that is in any memory variable in my called class will still reside there...right?
DavidCrow wrote:
We'd be in a world of hurt if passing pointers caused destructors to be called.
Sorry I did not phrase that right. I'm assuming that the destructor destroys that memory variable...but like you said above it will not destroy that pointer until the object is out of scope or deleted.
Can you give an example of when an object is out of scope? And is passing data this way a high risk for memory leaks or buffer overruns?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
This class is a generic class that has no base class to it. It is part of my main app.
Then it is a simple matter of accessing the class' member variable from the main app.
Tom Wright wrote:
So if the class has never been destroyed by my call app...by using the delete function (or goes out of scope)then any data that is in any memory variable in my called class will still reside there...right?
Correct.
Tom Wright wrote:
Can you give an example of when an object is out of scope?
void main( void )
{
int a;
{
int *x;
x = new int;
}
}
Tom Wright wrote:
And is passing data this way a high risk for memory leaks or buffer overruns?
Memory leaks and buffer overruns can happen in any situation. They are not limited to variables going out of scope. Consider:
class someclass
{
public:
void somefunction(int *n)
{
a = n;
}
private:
int *a;
};
void main( void )
{
someclass sc;
{
int x = 5;
sc.somefunction(&x);
}
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Why not granting the application a member of type this class?
The destructor will destroy all the statically declared variables. All the dynamically declared variables you have to excplicitely destroy in the destructor.
If the pointer you passed is pointing to some object allocated on the stack, then the pointer will be invalid as soon as the object is out of scope.
If you want the object to be "alive" when it is out of scope, you have to allocate it on the heap (using calloc, malloc (C) or new (C++))
This way the data will reside in memory untill you explicitly call delete on the pointer.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Okay so in my calling app I could put this:
CGCICsettings* mySettings = new CGCICsettings;<br />
<br />
mySettings->GetRegSettings();<br />
mySettings->ipAddress;<br />
First I call my function call GetRegSettings(); Which is in my new class. It (the function) fills in a variable called ipaddress, which I'll be able to access this data, which is what I'm doing in mySettings->ipAddress. Right? After I'm done with this I delete it.
Does this sound right?
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
What you have looks ok, but without seeing how/where mySettings is used, I suspect allocating the CGCICsettings object on the heap is unnecessary. For example:
void somefunction( void )
{
CGCICsettings* mySettings = new CGCICsettings;
mySettings->GetRegSettings();
delete mySettings;
} In this context, a heap-based object is totally unnecessary.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi!
I've got a listbox, and the function (created with the classwizzard) that deals with the ONDBLCLICK message.
How do i get the text of the listbox item that i just dobleclicked?
thanks!!
|
|
|
|
|
Like this:
int nIndex = GetCurSel();
CString strText;
GetText(nIndex, strText);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
I am working on a project. I have to convert some files ( perhaps HTML,MHTML,Doc,Txt etc.) into a single CHM,and also, the User can reload the CHM that had been generated for some modification. I don't even konw how to make and modify a CHM file using MFC. I am using Visual C++ 6.0. I hope some one could give a example. It could just cover only HTML2CHM and reload HTML from CHM for simple.
Thank you very much!
|
|
|
|