Re: Releasing Dir() Search Handle

Tech-Archive recommends: Speed Up your PC by fixing your registry



You cannot have a folder called nul Peter. nul is a special file name, just
like com1, etc

See http://msdn.microsoft.com/en-us/library/aa365247.aspx

Tony

"PeterD" <peter2@xxxxxxxxxx> wrote in message
news:n5pp64l3ktrnob8nk20lbf6fcr7pqkdp50@xxxxxxxxxx
On Wed, 2 Jul 2008 17:39:15 -0700, "Karl E. Peterson" <karl@xxxxxxxx>
wrote:

Hi Folks --

I just wanted to be sure about something, so I wrote up a little test...

Option Explicit

Private Sub Command1_Click()
Debug.Print Dir("c:\*.*")
End Sub

Private Sub Command2_Click()
Debug.Print Dir("nul")
End Sub

Compiling that, and watching it in TaskMgr, I see the Handle count rise
when I press
Command1 and drop when I press Command2. I've tried googling for this, to
no avail,
but I know I've seen threads here before about releasing the search handle
VB
creates by calling FindFirstFile on a Dir.

I did find posts suggesting that passing vbNullString would do it too, but
that
doesn't seem to be the case given the above test. Anyone have any
thoughts on this?

Thanks... Karl

In Dir("nul") you (probably) don't have a folder named "nul" so the
dir command completes, and frees its handle? I think you will find the
same is true when the Dir() is called (no parameter) sufficiently to
enumerate all the items in the given folder based on the first call
that creates the handle.


.



Relevant Pages

  • Re: How to run rule against something other than Inbox with VBA?
    ... specified folder to a "Marked As Read" status. ... Dim WithEvents olkFolder As Outlook.Items ... Set olkFolder = Nothing ... Private Sub Application_Startup ...
    (microsoft.public.outlook.program_vba)
  • Re: Outlook Heute Gesendete Mails
    ... This works by monitoring the Sent Items folder. ... Private Sub Application_Startup ... Dim olkFolder As Outlook.MAPIFolder ... Alle emails die im Betreff Privat haben werden in diesen Ordner automatisch verschoben. ...
    (microsoft.public.de.exchange)
  • Re: multiple xml imports from local path
    ... > Dirto loop through all the files in a folder. ... > Private Sub btnImportAllFiles_Click ... > Dim strfile As String ...
    (microsoft.public.access.externaldata)
  • Re: Why doesnt Item.ItemAdd event work?
    ... The one known issue is that ItemAdd won't fire if more than 16 items are added to the folder at one time. ... Author of Configuring Microsoft Outlook 2003 ... > Dim InboxMails As Items ... > Private Sub InboxMails_ItemAdd ...
    (microsoft.public.outlook.program_vba)
  • RE: Outlook + Excel
    ... folder that you specify, and then you can work with the message in any way ... Private Sub Class_Initialize ... Set objMonitoredFolder = objNS.GetDefaultFolder ... Set objFldr = ActiveExplorer.CurrentFolder ...
    (microsoft.public.outlook.program_vba)