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,648 of 10,840   
   Don to All   
   Detect file opened by Notepad   
   13 Sep 08 17:28:13   
   
   XPost: microsoft.public.vb.general.discussion, microsoft.public.vb   
   From: dsarvas@yahoo.com   
      
   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   
      
   --- 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