CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    20

    VB open new program on cd rom

    I have a small quesiton here -

    I have found a lot of info on opening another program from VB6, however, I have an addition that I need some advice on......

    I have a small VB6 program that when the user puts the CD into the disk drive then my .exe file will be called from the autorun.inf file. When this occurs my vb program will ask what the user would like to do.

    There will be 3 options, however, 2 of the 3 will be calling another program located to the disk. This other program will actually be a VB.NET 2008 project.

    Is there anyway to call another program located on the disk not knowing what drive the user will have set as there CD-ROM?

    Example: if I call the program from the D: drive and the user has the disk in the E: drive then the program can't find the next one.....

    Hope this makes sense......

    Thanks in advanced

    daveofgv

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB open new program on cd rom

    How about this?

    Code:
    Option Explicit
    
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    Private Sub Form_Load()
        'KPD-Team 1998 - modified by dglienna
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
    
        Dim Path As String, strSave As String, strSave2 As String
        'Create a buffer string
        strSave = String(200, Chr$(0))
        strSave2 = String(200, Chr$(0))
        'Get the windows directory and append 'REGEdit.exe' to it
        MsgBox Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))
        MsgBox Left$(strSave2, GetSystemDirectory(strSave2, Len(strSave)))
    
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured