|
-
Feb 18th, 2007, 02:27 AM
#1
Thread Starter
Hyperactive Member
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?
-
Feb 18th, 2007, 02:32 AM
#2
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
-
Feb 18th, 2007, 02:51 AM
#3
Thread Starter
Hyperactive Member
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?
-
Feb 18th, 2007, 03:01 AM
#4
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
-
Feb 18th, 2007, 03:12 AM
#5
Re: Need Help Opening The D:\ Drive
Something along these lines will open and close the cdrom tray.
VB Code:
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 opencd()
mciSendString("set CDAudio door open", 0, 0, 0)
End Sub
Private Sub closecd()
mciSendString("set CDAudio door closed", 0, 0, 0)
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 03:25 AM
#6
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
-
Feb 18th, 2007, 03:29 AM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 03:34 AM
#8
Re: Need Help Opening The D:\ Drive
Code for 2003/2005 in the simplest method...
VB 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 btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
mciSendString("set CDAudio door closed", "0", 0, 0)
End Sub
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
mciSendString("set CDAudio door open", "0", 0, 0)
End Sub
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 03:37 AM
#9
Re: Need Help Opening The D:\ Drive
Nice Code By You Thanks
-
Feb 18th, 2007, 03:45 AM
#10
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 02:44 PM
#11
Thread Starter
Hyperactive Member
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...
-
Feb 18th, 2007, 02:45 PM
#12
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 02:58 PM
#13
Thread Starter
Hyperactive Member
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.
-
Feb 18th, 2007, 03:04 PM
#14
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 03:48 PM
#15
Thread Starter
Hyperactive Member
Re: Need Help Opening The D:\ Drive
i used the exact one you posted
-
Feb 18th, 2007, 03:53 PM
#16
Thread Starter
Hyperactive Member
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.
-
Feb 18th, 2007, 04:10 PM
#17
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 04:21 PM
#18
Thread Starter
Hyperactive Member
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...
-
Feb 18th, 2007, 04:33 PM
#19
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 05:12 PM
#20
Thread Starter
Hyperactive Member
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
-
Feb 18th, 2007, 05:22 PM
#21
Re: Need Help Opening The D:\ Drive
Ok, then try this.
VB Code:
Option Explicit On
Option Strict On
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("winmm", EntryPoint:="mciSendString")> _
Private Shared Function mciSendString( _
<MarshalAs(UnmanagedType.LPWStr)> ByVal lpszCommand As String, _
<MarshalAs(UnmanagedType.LPWStr)> ByVal lpszReturnString As String, _
ByVal cchReturnLength As Integer, _
ByVal hwndCallback As Integer) As Integer
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
mciSendString("set CDAudio door closed", "0", 0, 0)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mciSendString("set CDAudio door open", "0", 0, 0)
End Sub
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
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Feb 18th, 2007, 06:10 PM
#22
Thread Starter
Hyperactive Member
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...
-
Feb 18th, 2007, 06:23 PM
#23
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|