

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúusing System;
using System.Text;
using System.Runtime.InteropServices;
namespace EjectMedia
{
class Program
{
static void Main(string[] args)
{
// My CDROM is on drive E:
EjectMedia.Eject(@"\\.\E:");
}
}
class EjectMedia
{
// Constants used in DLL methods
const uint GENERICREAD = 0x80000000;
const uint OPENEXISTING = 3;
const uint IOCTL_STORAGE_EJECT_MEDIA = 2967560;
const int INVALID_HANDLE = -1;
// File Handle
private static IntPtr fileHandle;
private static uint returnedBytes;
// Use Kernel32 via interop to access required methods
// Get a File Handle
[DllImport("kernel32", SetLastError = true)]
static extern IntPtr CreateFile(string fileName,
uint desiredAccess,
uint shareMode,
IntPtr attributes,
uint creationDisposition,
uint flagsAndAttributes,
IntPtr templateFile);
[DllImport("kernel32", SetLastError=true)]
static extern int CloseHandle(IntPtr driveHandle);
[DllImport("kernel32", SetLastError = true)]
static extern bool DeviceIoControl(IntPtr driveHandle,
uint IoControlCode,
IntPtr lpInBuffer,
uint inBufferSize,
IntPtr lpOutBuffer,
uint outBufferSize,
ref uint lpBytesReturned,
IntPtr lpOverlapped);
public static void Eject(string driveLetter)
{
try
{
// Create an handle to the drive
fileHandle = CreateFile(driveLetter,
GENERICREAD,
0,
IntPtr.Zero,
OPENEXISTING,
0,
IntPtr.Zero);
if ((int)fileHandle != INVALID_HANDLE)
{
// Eject the disk
DeviceIoControl(fileHandle,
IOCTL_STORAGE_EJECT_MEDIA,
IntPtr.Zero, 0,
IntPtr.Zero, 0,
ref returnedBytes,
IntPtr.Zero);
}
}
catch
{
throw new Exception(Marshal.GetLastWin32Error().ToString());
}
finally
{
// Close Drive Handle
CloseHandle(fileHandle);
fileHandle = IntPtr.Zero;
}
}
}
}
Dim dia As Integer
Dim mes As Integer
Dim reponse As Boolean
Private Sub Form_Load()
dia = InputBox("Ingrese dia", "Signos")
mes = InputBox("Ingrese mes", "Signos")
Select Case mes
Case 1
If dia < 21 Then
reponse = MsgBox("CAPRICORNIO", vbOKOnly)
Else: reponse = MsgBox("ACUARIO", vbOKOnly)
End If
Case 2
If dia < 20 Then
reponse = MsgBox("ACUARIO", vbOKOnly)
Else: reponse = MsgBox("PISCIS", vbOKOnly)
End If
Case 3
If dia < 21 Then
reponse = MsgBox("PISCIS", vbOKOnly)
Else: reponse = MsgBox("ARIES", vbOKOnly)
End If
Case 4
If dia < 21 Then
reponse = MsgBox("ARIES", vbOKOnly)
Else: reponse = MsgBox("TAURO", vbOKOnly)
End If
Case 5
If dia < 21 Then
reponse = MsgBox("TAURO", vbOKOnly)
Else: reponse = MsgBox("GEMINIS", vbOKOnly)
End If
Case 6
If dia < 22 Then
reponse = MsgBox("GEMINIS", vbOKOnly)
Else: reponse = MsgBox("CANCER", vbOKOnly)
End If
Case 7
If dia < 23 Then
reponse = MsgBox("CANCER", vbOKOnly)
Else: reponse = MsgBox("LEO", vbOKOnly)
End If
Case 8
If dia < 23 Then
reponse = MsgBox("LEO", vbOKOnly)
Else: reponse = MsgBox("VIRGO", vbOKOnly)
End If
Case 9
If dia < 23 Then
reponse = MsgBox("VIRGO", vbOKOnly)
Else: reponse = MsgBox("LIBRA", vbOKOnly)
End If
Case 10
If dia < 23 Then
reponse = MsgBox("LIBRA", vbOKOnly)
Else: reponse = MsgBox("ESCORPIO", vbOKOnly)
End If
Case 11
If dia < 22 Then
reponse = MsgBox("ESCORPIO", vbOKOnly)
Else: reponse = MsgBox("SAGITARIO", vbOKOnly)
End If
Case 12
If dia < 22 Then
reponse = MsgBox("SAGITARIO", vbOKOnly)
Else: reponse = MsgBox("CAPRICORNIO", vbOKOnly)
End If
Case Else
reponse = MsgBox("Error")
End Select
End Sub