Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dir(), WinAPI Question 1

Status
Not open for further replies.

BrooksR

Programmer
Feb 24, 2001
98
US
I’m working in a network environment.

If I do:

strFile = Dir("\\(some user’s machine)\C$\Documents and Settings\All Users\Desktop\*.*")

to test the connection to a user’s machine and their machine is turned off or in sleep mode, I will get an error 52 (“bad file name or number”).

This is ok except for how long it takes – about 45 seconds. Sometimes there are a lot of these in a loop which takes a long time …

Is there a Windows API call or other function that might return results faster?

Thanks,
Brooks

 
How are ya BrooksR . . .

There are several APIs available. One in particularly is [blue]PathIsDirectory[/blue]. To install it, in the declarations section of a module in the modules window, copy/paste the following line:
Code:
[blue]Public Declare Function PathIsDirectory Lib "shlwapi.dll" Alias "PathIsDirectoryA" (ByVal pszPath As String) As Long[/blue]
Thats it. The function returns true if the path exists, false otherwise. Example of use follows:
Code:
[blue]   Dim Path As String
   
   Path = "C:\Database\Contact"
   
   If PathIsDirectory(Path) Then
      Debug.Print True
   Else
      Debug.Print False
   End If[/blue]
A look at All API reveals quite a few [blue]PathIs ...[/blue] functions.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top