Quote Originally Posted by BigJay
Ok, I need some assistance with VB6. I have two items that I can't seem to find information on. Here is what I am needing:

1. I need to be able to determine, through VB6 itself, what the users computer is using for its default web browser. I can do it through ASP but I can't seem to determine through VB.

2. I need to know how to determine if a file is already open or not. My program has 4 separate main programs to it. I need to be able to determine how to know if any of those 4 programs are open if at all possible.

Thanks.

BigJay
To get the default browser, use something like this. Start a new project, and replace all code in the form with this:

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" (ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
  4.  
  5. Private Function LongPath(ByVal ShortPath As String) As String
  6.     Dim lonRet As Long, strLong As String
  7.    
  8.     strLong = String$(1024, " ")
  9.     lonRet = GetLongPathName(ShortPath, strLong, Len(strLong))
  10.    
  11.     If lonRet > Len(strLong) Then
  12.         strLong = String$(lonRet + 1, " ")
  13.        
  14.         lonRet = GetLongPathName(ShortPath, strLong, Len(strLong))
  15.     End If
  16.    
  17.     If lonRet > 0 Then
  18.         LongPath = Left$(strLong, lonRet)
  19.     End If
  20.    
  21. End Function
  22.  
  23. Private Function DefaultBrowser() As String
  24.     Dim strReg As String, objReg As Object
  25.    
  26.     Set objReg = CreateObject("Wscript.Shell")
  27.     strReg = objReg.regread("HKEY_CLASSES_ROOT\HTTP\shell\open\command\")
  28.     strReg = Replace$(strReg, Chr$(34), "")
  29.     strReg = Mid$(strReg, 1, InStr(1, strReg, ".exe", vbTextCompare) + 3)
  30.     DefaultBrowser = strReg
  31. End Function
  32.  
  33. Private Sub Form_Load()
  34.     Dim strBrowser As String
  35.    
  36.     strBrowser = LongPath(DefaultBrowser)
  37.     MsgBox strBrowser
  38. End Sub

To find if one of your programs are open or not, you can use the FindWindow() API function. There is code for this in the CodeBank.