Results 1 to 3 of 3

Thread: VB6 question-Determine Browser and open files

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    13

    VB6 question-Determine Browser and open files

    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

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: VB6 question-Determine Browser and open files

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    13

    Re: VB6 question-Determine Browser and open files

    Great. This helps alot.

    I have a question on detecting an open program. A little more in depth is that the program(s) I need to watch for open would be running through a network and they could be running on another computer on the network, not the computer that is running the program trying to detect open programs. How can I detect a program being open on any machine on the network that may not be running on that specific machine?

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width