home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,677 of 10,840   
   Dean Earley to Don   
   Re: Detect file opened by Notepad   
   15 Sep 08 14:54:51   
   
   From: dean.earley@icode.co.uk   
      
   Don wrote:   
   > I wrote an app that alerts a user who attempts to open a file that the   
   > file is currently in use.  It works fine except when the file is   
   > opened by Notepad.  If a text file is opened, most computers are   
   > configured to use Notepad to open the file by default and if they are   
   > configured to use Notepad by default I want it to remain that way   
   > rather than retrieve the text into my app or force the user to use   
   > another app to read the file.  I'm using the following code I found   
   > online and lErrNum returns a value of zero if Notepad has the file   
   > open but returns 70 when most other files are open using another   
   > application.   
   >   
   > Don   
   >   
   > Open sPathFile For Input Lock Read As #iFileNum   
   > Close iFileNum   
   > lErrNum = Err.Number   
   > On Error GoTo 0   
   >   
   > Select Case lErrNum   
   >     Case 0 'No error occurred.  File is NOT already open by another   
   > user.   
   >         FileIsOpen = False   
   >     Case 70 'Error number for "Permission Denied." File is already   
   > opened by another user.   
   >         FileIsOpen = True   
   >     Case 53 'File not found   
   >         FileIsOpen = False   
   >     Case Else 'Another error occurred.   
   >         FileIsOpen = True   
   >         MsgBox Error(lErrNum)   
   > End Select   
      
   As mentioned numerous times through this thread, notepad doesn't keep   
   the file open.   
   You may be able to do it with a tiny stub exe that opens the file, then   
   shells out to notepad and waits for the process to exit.   
   That will break if they then use that notepad process to open other files.   
      
   --   
   Dean Earley (dean.earley@icode.co.uk)   
   i-Catcher Development Team   
      
   iCode Systems   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca