Results 1 to 23 of 23

Thread: Need Help Opening The D:\ Drive

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Need Help Opening The D:\ Drive

    this is the code i have so far... it will bring up the drive on my screen... but i want to physically open the drive... so far, this code only tells me "please insert a cd into drive d:\"

    Code:
        If TextBox2.Text = "d:\" Then
                Process.Start("d:\")
            End If
    i have the set up to view the contents on all my drives 1 by 1... how do i open and close the drive though?

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Need Help Opening The D:\ Drive

    I think you are trying to opening a CDROM using the process other wise it is working for the C:\drive

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    yeah, that's what i said... it works for all of my drives... it just won't physically open a drive... is there a way to do that?

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: Need Help Opening The D:\ Drive

    Put the CD Inside the CDROM and check it will work and show you the file related to the CD

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Something along these lines will open and close the cdrom tray.
    VB Code:
    1. Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
    2.                 ByVal lpszCommand As String, _
    3.                 ByVal lpszReturnString As String, _
    4.                 ByVal cchReturnLength As Long, _
    5.                 ByVal hwndCallback As Long) As Long
    6.  
    7. Private Sub opencd()
    8.     mciSendString("set CDAudio door open", 0, 0, 0)
    9. End Sub
    10.  
    11. Private Sub closecd()
    12.     mciSendString("set CDAudio door closed", 0, 0, 0)
    13. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Question Re: Need Help Opening The D:\ Drive

    Sir
    I want to know that the above code is for the hardware part or the software part
    Means that it open the CD Drive file or it open the CD Drive for putting CD in it.
    Thanks

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Software part where you click a button and the CDROM door will open. Then click another button and the door will close.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Code for 2003/2005 in the simplest method...

    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Public Class Form1
    5.  
    6.     Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
    7.                 ByVal lpszCommand As String, _
    8.                 ByVal lpszReturnString As String, _
    9.                 ByVal cchReturnLength As Long, _
    10.                 ByVal hwndCallback As Long) As Long
    11.  
    12.     Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
    13.         mciSendString("set CDAudio door closed", "0", 0, 0)
    14.     End Sub
    15.  
    16.     Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
    17.         mciSendString("set CDAudio door open", "0", 0, 0)
    18.     End Sub
    19.  
    20. End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: Need Help Opening The D:\ Drive

    Nice Code By You Thanks

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Thanks.


    @conflix, please dont post duplicate threads.
    http://vbforums.com/showthread.php?t=453244
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    i'm not sure what i'm doing wrong... but here's what i'm getting

    "Declare" is not valid as an identifier

    and "mcisendstring" is not declared

    i've been playing with this for hours. any help would be appreciated... lol... i feel so dumb...

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Copy/Paste my code example behind a form in a new project/solution, add two buttons named appropriately and viola.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    ok, i got it to work, but it gives me this error...

    Code:
    mciSendString("set CDAudio door open", "0", 0, 0)
    A call to PInvoke function 'BestFriend!WindowsApplication1.Form1::mciSendString' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Thats a message stating that you have a different API declared then the arguments you are passing to it. Did you use what I posted or a variation of it?

    ByVal lpszReturnString As String is for the "0" argument. Yours may be different.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    i used the exact one you posted

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    the code works, but when i click the button... it gives me the error message... but the drive door does open.

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    In a separate new project or in your already existing project?
    As I was mentioning, you may not have the same code as my posted example. You need to verify that first.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    sorry... it's in an existing project...

    i copied and pasted your code... i didn't modify anything... i hope that helps...

  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Where is the API (mciSendString) declaration? And is it exactly as in my code? Post your code.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    Code:
    Option Explicit On
    Option Strict On
    
    
    Public Class Form1
    
        Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
                    ByVal lpszCommand As String, _
                    ByVal lpszReturnString As String, _
                    ByVal cchReturnLength As Long, _
                    ByVal hwndCallback As Long) As Long
    
        Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            mciSendString("set CDAudio door open", "0", 0, 0)
    
            Button3.Hide()
            TextBox2.Show()
            Button1.Show()
    
        End Sub

  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    Ok, then try this.

    VB Code:
    1. Option Explicit On
    2. Option Strict On
    3.  
    4. Imports System.Runtime.InteropServices
    5.  
    6. Public Class Form1
    7.  
    8.     <DllImport("winmm", EntryPoint:="mciSendString")> _
    9.     Private Shared Function mciSendString( _
    10.                 <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszCommand As String, _
    11.                 <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszReturnString As String, _
    12.                 ByVal cchReturnLength As Integer, _
    13.                 ByVal hwndCallback As Integer) As Integer
    14.     End Function
    15.  
    16.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    17.         mciSendString("set CDAudio door closed", "0", 0, 0)
    18.     End Sub
    19.  
    20.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    21.         mciSendString("set CDAudio door open", "0", 0, 0)
    22.     End Sub
    23.  
    24.     Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    25.         mciSendString("set CDAudio door open", "0", 0, 0)
    26.         Button3.Hide()
    27.         TextBox2.Show()
    28.         Button1.Show()
    29.     End Sub
    30.  
    31. End Class
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Location
    Las Vegas, NV
    Posts
    301

    Re: Need Help Opening The D:\ Drive

    lol... that doesn't give me any errors when i try it... but now the problem is... lol... the door won't open... i've been looking at the code, but have no idea why it won't open now...

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need Help Opening The D:\ Drive

    If you have encountered any errors earlier then try a reboot to reset the drive. I got one before and it was resolved with a reboot.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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