Click here to Skip to main content
15,920,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Learning how to parse XML file in C++ Pin
David Crow27-Jul-05 3:04
David Crow27-Jul-05 3:04 
Questioncan we stop dialog from exiting when i click on red cross button? Pin
sayup26-Jul-05 21:56
sayup26-Jul-05 21:56 
AnswerRe: can we stop dialog from exiting when i click on red cross button? Pin
mark novak27-Jul-05 0:38
mark novak27-Jul-05 0:38 
AnswerRe: can we stop dialog from exiting when i click on red cross button? Pin
Stlan27-Jul-05 0:54
Stlan27-Jul-05 0:54 
GeneralRestarting an application from within the same application Pin
ledallam26-Jul-05 18:52
ledallam26-Jul-05 18:52 
GeneralRe: Restarting an application from within the same application Pin
GDavy26-Jul-05 20:02
GDavy26-Jul-05 20:02 
GeneralRe: Restarting an application from within the same application Pin
Smith#26-Jul-05 22:21
Smith#26-Jul-05 22:21 
GeneralRe: Restarting an application from within the same application Pin
Smith#26-Jul-05 22:22
Smith#26-Jul-05 22:22 
GeneralRe: Restarting an application from within the same application Pin
ledallam27-Jul-05 0:37
ledallam27-Jul-05 0:37 
GeneralRe: Restarting an application from within the same application Pin
David Crow27-Jul-05 3:07
David Crow27-Jul-05 3:07 
QuestionHow can I export a Dialog class in MFC regular Dll or Extension Dll? Pin
guiguizk26-Jul-05 18:43
guiguizk26-Jul-05 18:43 
AnswerRe: How can I export a Dialog class in MFC regular Dll or Extension Dll? Pin
GDavy26-Jul-05 20:08
GDavy26-Jul-05 20:08 
GeneralRe: How can I export a Dialog class in MFC regular Dll or Extension Dll? Pin
guiguizk26-Jul-05 20:47
guiguizk26-Jul-05 20:47 
Questionhow can i transprant a child dialog's background? Pin
SamSmithCn26-Jul-05 17:35
SamSmithCn26-Jul-05 17:35 
AnswerRe: how can i transprant a child dialog's background? Pin
mark novak27-Jul-05 0:33
mark novak27-Jul-05 0:33 
GeneralPath Name Pin
Veera Raghavendra26-Jul-05 17:23
Veera Raghavendra26-Jul-05 17:23 
GeneralRe: Path Name Pin
Bob Stanneveld26-Jul-05 23:14
Bob Stanneveld26-Jul-05 23:14 
GeneralRe: Path Name Pin
Veera Raghavendra26-Jul-05 23:16
Veera Raghavendra26-Jul-05 23:16 
GeneralRe: Path Name Pin
David Crow27-Jul-05 3:09
David Crow27-Jul-05 3:09 
GeneralRe: Path Name Pin
Toby Opferman27-Jul-05 14:28
Toby Opferman27-Jul-05 14:28 
It is actually harder than just that.

A filter driver on the file system(s) will allow you to capture open/close/read/write, etc. so you would be able to find out the LAST file that notepad had opened or created. The problem is that notepad does not hold the file handle open, it closes it after is reads it or saves the file. So, you would need to keep a list of PID's and "last opened" files. Of course, you would need to differentiate the file opened for "putting in notepad's window" verse opening some configuration file by some system component.

Even so, if you could solve that you would then need to clean the list of PID's so you don't keep growing them indefinately. This could again be solved by registering for process creation and destruction.

The final problem is that since notepad doesn't keep the file open, you can actually just select "New" and create a new untiled file without doing any disk access at all. So infact, notepad wouldn't have the file you previously opened in it anymore.

Now, here's a secret. There is a global variable in notepad called "notepad!szFileName". This is the file name that was opened. You would then just need to get notepad's current directory (Hopefully hasn't changed since the file was opened) and then relate it to reading this global variable from notepad's memory. If this global says "Untitled" then it's a new file.

So, how do you find the offset to this? Well you could simply hard code the offset based on a particular version of notepad, but the Microsoft symbol server has the symbols. So you could write a client that could then talk to the symbol server and request the PBD symbol file for that version of notepad, then read the offset into the file where it is and read the file name.

Alternatively, you could just "GetWindowText" and read the title bar of notepad. Of course this doesn't include the ".txt" extension if it's being used so "x.txt" and "x." look the same. Also, it includes no directory information so you're kind of stuck guessing where the file is on the system.

You could read the command line from the application, but then again you don't know if they've saved, closed the file and opened a new one. You could even hook "CreateFileW" in notepad, but you would never know if they used "new" and you also wouldn't tell the difference between when they are opening a file for editing or if some component is opening a file for settings or something else.



The moral of the story is that if you want to keep track of what file is being edited, why don't you just write your own editor.




8bc7c0ec02c0e404c0cc0680f7018827ebee
GeneralLockFileEx Pin
Anonymous26-Jul-05 16:48
Anonymous26-Jul-05 16:48 
GeneralEnumerating NICs Pin
franji126-Jul-05 16:46
franji126-Jul-05 16:46 
GeneralRe: Enumerating NICs Pin
Ted Ferenc26-Jul-05 21:49
Ted Ferenc26-Jul-05 21:49 
Generalnot whats needed Re: Enumerating NICs Pin
franji127-Jul-05 2:04
franji127-Jul-05 2:04 
GeneralFile transfer thru bluetooth USB Pin
cheewooi26-Jul-05 13:27
cheewooi26-Jul-05 13:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.