Results 1 to 8 of 8

Thread: [RESOLVED] Detect where it's running from....

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    24

    Resolved [RESOLVED] Detect where it's running from....

    I've got a little application that plays videos/mp3's. I want to place the application and associated avi's/mp3's on a DVD and play everything from the
    dvd. How do I determine if the dvd is loaded in the D:, E:, or F: drive?

    In other words the user loads the DVD into a drive, clicks on an executable, and my program knows which drive the DVD is in.

    Thanks for everyones help!
    doug

  2. #2
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Detect where it's running from....

    What does that actually mean?
    Do you want to find out what is the drive name for the user's optical disk, or what?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    24

    Re: Detect where it's running from....

    No, just the drive letter. My work computer has several DVD drives, some people have a CD & DVD drive. So if the program is loaded into my E: drive,
    the application will know that the required avi's/mp3 are in the E: drive.

    Same thing if it's loaded into the D: drive or the F: drive - I just don't know
    how to code "if this application is executed from drive d: then avi's/mp3's are
    also on drive d:....

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    24

    Re: Detect where it's running from....

    found this little bit of code after a couple of hours of searching.
    Worked like a charm!!!!!

    If Right$(App.Path, 1) = "\" Then
    Target = App.Path & "\demo.avi"
    Else '
    Target = App.Path & "\demo.avi"
    End If

  5. #5
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: [RESOLVED] Detect where it's running from....

    You do realize that both cases in the If statement amount to the same thing?

    Perhaps you were looking for this
    vb Code:
    1. If Right$(App.Path, 1) = "\" Then
    2.      Target = App.Path & "demo.avi"
    3. Else '
    4.      Target = App.Path & "\demo.avi"
    5. End If

  6. #6
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: [RESOLVED] Detect where it's running from....

    But I prefer the code:
    vb Code:
    1. Option Explicit
    2.  
    3. Public AppPath as String
    4.  
    5. Private Sub Main()
    6.  
    7.      AppPath = App.Path
    8.      if Right$(AppPath, 1) <> "\" then AppPath = AppPath & "\"
    9.  
    10. End Sub
    In this way you just use AppPath everywhere you would normally use App.Path and you don't have to code all the extra lines of code each time... The all you would need to do is:
    vb Code:
    1. Target = AppPath & "demo.avi"

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    24

    Re: [RESOLVED] Detect where it's running from....

    Excellent, I'll try the other way Monday. I'm ashamed to admit I don't know what the Right$ does....

  8. #8
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: [RESOLVED] Detect where it's running from....

    That's where DOCUMENTATION comes in, but you do have to read it...

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