?
Solved

visual basic 6 determine if computer is on network

Posted on 2009-04-03
2
Medium Priority
?
222 Views
Last Modified: 2012-05-06
I want to determine if a computer is running using vb 6.0. I am implementing a fail-over system and wanted something that returns the information quickly
0
Comment
Question by:adimit
2 Comments
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 24066741
Here´s a very quick and dirty way to do with vbscript. You can´t do itwith VB as the application will fail to load if the redistributablesaren´t installed!

Option Explicit
 
Const SYSTEM32 = &H25&
 
Dim objShell, objFolder, objFolderItem, objFSO, sPath, sFile
 
Set objShell = CreateObject("Shell.Application")
Set objFSO =  CreateObject("Scripting.FileSystemObject")
Set objFolder = objShell.Namespace(SYSTEM32)
Set objFolderItem = objFolder.Self
 
sPath = objFolderItem.Path
 
If Right(sPath,1) <> "\" Then sPath = sPath & "\"
 
sFile = sPath & "Msvbvm60.dll"
If objFSO.FileExists( sFile ) Then
    Wscript.Echo "VB6 Installed"
End If
 
sFile = sPath & "Msvbvm50.dll"
If objFSO.FileExists( sFile ) Then
    Wscript.Echo "VB5 Installed"
End If

Open in new window

0
 
LVL 10

Accepted Solution

by:
Chad Smith earned 2000 total points
ID: 24093798
Check if a network file exists

Function FileExist(sTestFile As String) As Boolean
   'This function does not use DIR since it is possible that you might have
   'been in the middle of running DIR against another directory in
   'an attempt to match one directory against another.

   'It does not handle wildcard characters
   Dim lSize As Long
   On Error Resume Next
   'Preset length to -1 because files can be zero bytes in length
   lSize = -1
   'Get the length of the file
   lSize = FileLen(sTestFile)
   If lSize > -1 Then
      FileExist = True
   Else
      FileExist = False
   End If
End Function
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question