Link to home
Start Free TrialLog in
Avatar of vinaysamant
vinaysamant

asked on

Trapping "Save" & "Save As" all over windows

Hello Xperts,
There are 2 requirements regarding save -
1. i want to trap "Save" & "Save As" dialog or event before even it appears. So when ever some press "Save" or "Save As" & i should be able to know and if needed I should be able to kill it.
2. If i allow to show Save Dialog Box, & if user writes name of file & other informations & press "Save" / "Ok" button then i should be able to retrieve that information & stop that also if i decide.

This decision of killing will depend on some exe types which i will take. I have that code of trapping all windows ready with me. Hel pme out in this!

Regards,
Vinay Samant.

I have assigned 40 points this as this is very easy & already available on EE. If you want more & u r sure abt ur code which will produce same effects on all windows platform then pls let me know!
Avatar of zzzzzooc
zzzzzooc

>> I have assigned 40 points this as this is very easy & already available on EE

Really? :-) Not sure I've come across a system-wide hook for Common Dialog API before.
Why dont you go get it in the question where it is already available?
Avatar of vinaysamant

ASKER

When i received a message that there r comments on Save question, i came with so many hopes. And you people are just kidding! zzz you have already attended my previous question so nicely! Then y r u kidding? And when i searched EE I found many answers, but as i m not premium member, i cant see them! I dont want to to say that its dirt easy, If you think its very hard, let me know... if you want more points, i m ready to assign! I already specified that. Otherwise can u just give me some directions about how to get through that then i will myself also like to learn. Please cooperate.

zzzz have u seen my 2nd question at -
https://www.experts-exchange.com/questions/20944180/Disabling-Print-menu-of-any-specific-application.html#10828825

let me know if you can help me there also? Most of it is solved, only 1 API need to be resolved!

Thanks Xperts!
Vinay Samant.
None of your questions are simple. If they were, you would have solved them yourself. The nature of most of your questions involves hooking into system-wide events which won't be easily done and worth atleast 500pts. I'm not trying to be rude. I'm just trying to state that these aren't "easy" as you mentioned.
Hi zzzzz,
I dont wanted to be stingy! Hence i specified that if some one want more points i can give them. No problems. He should specify.

I agree that these problems are not simple & bit difficult. BUT IT IS NOT THAT SOME THING HAPPENING FOR 1ST TIME! And you are trying to find out something which is not there any where documented. Like my previous question, answered by Ark[about to finish] was really really hard. But i dont see windows hooking & hotkey methods or dialog hooking is really hard. The documentation is available with msdn. Only problem with me is, I m not used to the methods of converting API code to VB code. I dont understand language of microsoft & there i get stuck. I have to wait for people like you to guide me. Hence I respect you and call you Experts. I frankly respect you! And at all dont want to fight with you as you also have answered my last question very nicely. It really solved problem.

But if you notice that question, some things were not solved. Like making application invisible in Task Manager, stopping it from getting killed. I used Cancel = 1 option for stopping it from getting killed but it dont work. Task Manager kills any process running. But look at nortan antivirus service. It cant kill that. Can we do somethig like that? I think that is really hard question. ISnt it?

Can you just guide me abt where should i go to get this code of Dialog hooking? Dont answer, i will try to find out on my own, just guide me abt how to go to that page which shows this information! Thanks a lot!

Take Care,
Vinay Samant.
Avatar of Ark
Hi
IMHO, it's not a difficult question. It's impossible. Windows itself haven't "Save" and "Save As" events/dialogs. Yes, there are GetOpen/SaveFilename API, but they are just a helpers which allow programmers show "window-looks" dialogs. Many applications (VB, MS Office) have their own dialog windows. You probably can use my Shell Hook (http://www.freevbcode.com/ShowCode.Asp?ID=1308) watching for window_created event with class name "#32770" ("magic" common dialog class name) and in this case you can trap standard common dialog creation. Then, enumerating child controls you can guess that this is Open/Save dialog if it has controls with following IDs:
     ID_OK = &H1  'Open or Save button
     ID_CANCEL = &H2 'Cancel Button
     ID_HELP = &H40E 'Help Button
     ID_FILETYPELABEL = &H441 'FileType label
     ID_FILELABEL = &H442 'FileName label
     ID_FOLDERLABEL = &H443 'Folder label
     ID_LIST = &H461 'Parent of file list
     ID_FILETYPE = &H470 'FileType combo box
     ID_FOLDER = &H471 'Folder combo box
     ID_FILETEXT = &H480 'FileName text box

Then, checking this window caption, or ID_OK button caption, or presence of  
     ID_READONLY = &H410 'Read-only check box
you can probably determine if this is Open or Save dialogs.

But all above fail if app create its own dialog window with own class name.

Regards
Ark
Nope! Just tested - since dialogs are child windows of main window, my shell hook doesn't trap their creation.
There is another techique available - API hook for specific functions. There are some samples on C++ available over the web (based on Matt Peterek and Jeff Richters books), but all them use standard dlls for system-wide hooks so can not be translated into VB. I did all my best trying to write VB API hook, but without success.
Ok Ark,
Is there any way to hook the disk activity, when file gets written to it ? And find out which application is writing that? Like UnDelete application find out recently deleted files & move them to different are to prevent them from getting permenantly erased. They must be using some api whch tells when a file is created, moved or deleted! Is this possible to find out?

Vinay Samant.
Hi,
thanks a lot for efforts u r taking. Just have a look here -
http://vbnet.mvps.org/code/comdlg/

Look at CallMsgFilter
http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/hooks.asp

nething possible to be done?
Also let me know if u have finished last question about my last requirement of protecting window from getting  killed by task manager! I will close it then!

Vinay Samant
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Ark,
No thats not my bid request. mu id on rentacoder is also vinaysamant. Are you member of RAC also? You must be minting money then! isnt it? There use to be many bids on RAC regarding API functions ;) Enjoy!

You have still not answered abt -
Also let me know if u have finished last question about my last requirement of protecting window from getting  killed by task manager! I will close it then.
To restrict closing your app you may try run your app as a service (http://www.vbwire.com/advanced/howto/service.asp)

As for RAC, I do some job there, but not so successfull as I want :)
BTW, if comparing prices here and there (for same Q), 1 EE pts = 2 USD. I'd like to convert all my points with this rate :)
Ark,
y dont u bid for that 80$ RAC request? Mostly you will get that. And your points are not worth 2USD. They are invaluable!
To be successful on RAC you have to get in database programming & web in big way. MySQL, JSP, PHP, VB! And most importent out of this is negociations on costing & getting project! Whats your id on RAC?

Vinay Samant
hi vinaysamant,

i may only help u out from part of ur question.

for invisible ur app in task manager just put a line of code
App.TaskVisible = False

applicable to win98, xp, 2000 n etc. with this line of code adding in u wont see ur app in "application" but u still see it in "processes".

hope it help

daniel