Results 1 to 5 of 5

Thread: help driveletter help

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    12

    Question

    I have files on a CD that are hyperlinked. I am using VB as a front end to the .pdf files that I have on that CD. If the CD drive is D: , I may want to:

    ShellExecute hwnd, "open", "D:\bookD.pdf", vbNullString, CurDir$, SW_SHOW

    but if the CD is Z: , then I may want it to point to:

    ShellExecute hwnd, "open", "Z:\bookZ.pdf", vbNullString, CurDir$, SW_SHOW

    that way I get the execution of the correct set of hyperlinked files.

    You get the picture....

    How do I determine what the driveletter is, and then get the (say button in my form) to point to the correct file???

    I don't know if I'm making this more difficult than it needs to be, but I don't know how else to do it.

    HELP!!??

  2. #2
    Lively Member
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    89

    Arrow

    there is an API cant remember what its name but it should be at http://www.vbapi.com/

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    12
    Is there another way to go about this??

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Here is a wrapper function that will get the first CD-Rom Drive letter:

    Code:
    
    Private Declare Function GetDriveType Lib "kernel32.dll" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
    Private Const DRIVE_CDROM = 5
    
    
    Public Function CDRomDriveLetter() As String
        Dim iCt As Integer
        Dim sCurDrv As String
        Dim lRet As Long
        
        For iCt = Asc("a") To Asc("z")
            
            sCurDrv = Chr(iCt) & ":\"
            lRet = GetDriveType(sCurDrv)
            
            If lRet = DRIVE_CDROM Then
                CDRomDriveLetter = sCurDrv
                iCt = Asc("z")
            End If
         
         Next iCt
         
    End Function
    The only way I can see this won't work is if the computer being checked has multiple cd-rom drives attached, this function will always return the first cd-rom drive found.

    (BTW here is the link klintsovi was thinking of http://www.vbapi.com/ref/g/getdrivetype.html )
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  5. #5
    Addicted Member
    Join Date
    Mar 2000
    Location
    Gainesville, FL
    Posts
    131
    Just strip it out of the app.path string!

    Code:
    Dim strDrive As String
    strDrive = Left$(App.Path, 3)
    MsgBox ("Hey, my drive letter is: " & strDrive)

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