|
When your aplication is closed, YOU MUST UNHOOK THE SYSTEM HOOK ALWAYS!
A system hook takes a lot of system resources, and is to long to explain here why, so unhook it using UnhookWindowsHookEx
Also, in you aplication create a button to hook/unhook your hook, that way you would be able to change the hook dll witout restarting.
Also, you must use a semaphore to check that only one instance of your aplication is running.
System hook's are a bit complicated at the beginning, I suggest you to check the theory in a lot of good articles in here.
Doing this, you shouldn't have more memory or performance leaks.
Good luck
|
|
|
|
|
Thanks for your reply.
Unfortunately it is not useful as I am using UnhookWindowsHookEx already while exiting.
Time of unreleasing DLL from memory get extended if I rerun application after terminating first instance.
Can you mention any links regarding using semaphore.
Thanks a lot.
Shivaji Patil
First deserve then desire. Let be deserve first.
|
|
|
|
|
Quoted:
" If I want to update/change my DLL file by terminating application Windows doesn't allow it. (As my development is going on,I have to do it). Only way to wait for some time or Log off/restart."
Your Unhook process isn't working fine, your hook DLL is still running when you close your application, that's why you never free those 8K.
Try closing all the hooked applications, after your unhook and check if the memory is back.
ABout the semaphore...
// Just one instance
hMutexOneInstance = CreateMutex(NULL, TRUE, "Your program ID");
if (GetLastError() == ERROR_ALREADY_EXISTS)
OnCancel();
if (hMutexOneInstance)
CloseHandle(hMutexOneInstance);
Paste that on your oninitdialog, and that's all.
"Your program ID" is any string you want to use.
Good luck
|
|
|
|
|
Thanks for reply.
Let me check.
First deserve then desire. Let be deserved first.
|
|
|
|
|
Thanks for response,
I solved my problem but by another way. I am sharing with you here.
First of all I released all set hooks.
Then I enumerate all processes for their IDs.
Then I opened each Process and list modules loaded with it.
I compared module's name with my dll name.
For matched Process (each) enumrated windows and child window.
For each window and child window I get ProcessId and compared with earlier ProcessId (EnumWindow caller Process).
For matched window and child window I send message which I hooked for my purpose using window handle.
This releases my DLL from every process which aquired it in its own memory map.
I can check List of such processes by Tlist command of Windows by using -m option.
To use such technique we have to consider its side effect also.
Thanks once again.
First deserve then desire. Let be deserved first.
-- modified at 0:52 Thursday 16th February, 2006
|
|
|
|
|
By default on our XP cleints the indexing service for folders is turned off, I want to set a folder and its files to have the indexing turned on, SetFileAttributes would seem to be the way of doing this but there does not seem to be a constant to do this, so what is the reverse of FILE_ATTRIBUTE_NOT_CONTENT_INDEXED ? Or anybody know how to do it in Window Script ? I've had a good search and cannot find anything, any help, as ever, will be much appreciated.
|
|
|
|
|
This should do the trick:
<br />
BOOL ToggleFileAttribute(LPSTR lpstrFileName,DWORD dwToggleAttribute)<br />
{<br />
DWORD dwFileAttributes = GetFileAttributes(lpstrFileName);<br />
DWORD newdwFileAttributes = dwFileAttributes & ~dwToggleAttribute;<br />
return SetFileAttribute(lpstrFileName,newdwFileAttributes );<br />
}<br />
<br />
<br />
if (ToggleFileAttribute("c:\\foo.dat",FILE_ATTRIBUTE_NOT_CONTENT_INDEXED))<br />
{<br />
}<br />
else<br />
{<br />
}<br />
<br />
If you want to do this on all the files in a folder and its subfolders, you'll need to write a function that can recursively traverse and toggle the FILE_ATTRIBUTE_NOT_CONTENT_INDEXED bit on each file.
-- modified at 8:42 Friday 3rd February, 2006
|
|
|
|
|
Thanks very much that will do nicely.
|
|
|
|
|
Don't forget to check the return value of GetFileAttributes() . If that fails and you don't check, SetFileAttributes() will munge the attributes, which is Bad.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
hi!!
where can i get information about "blackberry" apart from blackberry.com? thanks! -V.G
|
|
|
|
|
|
hi,
i have developed a dialog based appliation, it has a button "help" in it, it launches or shows the help when it is pressed, Besides that i would like to add the feature which launches the help when F1 is pressed.
how can i do that? any Sample code?
can anyone help me in this regard,
thanks in advance,
paul
|
|
|
|
|
y r not u using Accelarator?
God is real unless declared int..
|
|
|
|
|
Aryan S wrote: y r not u using Accelarator?
i think you're suggestion is pertinent.
however, why don't you speak an english that every one understand (i mean, well written) ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
i think he just came out of writting a long sms.
-Prakash
|
|
|
|
|
My application needs allocate disk space to some of it's directories.
For example: directory "Client1" with 2 mb and directory "Client2" with 3 mb
My application should be able to write data of (2+3) 5 mb to those
directories.
But with or *without* writing any data, The Windows should feel those
directories have taken that much space. Or when other applications check the
free disk space, Windows must show 5 mb less in the actual
space. IS any functions are there to partiton the hard disk and also to lock the folder
Please help me
-- modified at 7:00 Friday 3rd February, 2006
|
|
|
|
|
Well just fill a file with zeros ::- ).
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
I do not know if that is possible, directly.
Here is a way that you may be able to do it:
1) create a file that takes up the required space. This file contains no valid data, it is just a place holder. The idea here is just to insure that you have at least that much disk space to work with.
2) When you need to add another file to the directory, calculate how many bytes of data it will require. Then reduce the size of the place holder by that many bytes, before you save the new file. I recommend that durring testing, that you verify that the number of bytes you calculated matches the actual number of bytes required.
That should do the trick, but there are many other things you should consider provided that the number of bytes required might excceed what you think they will.
INTP
Every thing is relative...
|
|
|
|
|
ok sir
Is there any function specific how to partition the hard disk to allocate some space for my application,also how to lock (or) hide folder in vc
|
|
|
|
|
First, do not throw around the word partition so casualy. A partial answer would be yes, but only why your program is running. I am not talking about partitioning the hard-drive (do not even think of doing that), I am talking about reserving space on the disk. How you would do it I can not say, because I would need to do research just like you. I have a book around here some where that would probably tell me exactly how to do it. But the method I originaly sugested should work on any system, it does not require that your program be running in order for the space to be reserved.
INTP
Every thing is relative...
|
|
|
|
|
ok sir
Tell the some useful books which i could refer for memory management and i have one thing how to restrict the folder so that other user shoud not access my folder
|
|
|
|
|
How to allocate space dynamically to my application.Is there any functions to use and how can it be usefull explain me ok.
|
|
|
|
|
It *almost* sounds like you need to use sparse files.
Another solution would be to use SetFilePointer() /SetEndOfFile() pair.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi my name i Alberto , I'm new to this forum...
I'm still developing to a tapi service proveder in visual c++. This tapi service provider is a static library that is executed in svchost.exe and I want to pop up a message box when this tsp is called from a tapi application as outlook. How can I do?
I try to create a my CDialog or to use the afxMessageBox but don't go.
Please help me!!Thanks!!
|
|
|
|
|
what probs u facing with AfxMessageBox()?
God is real unless declared int..
|
|
|
|