greenant
...
.const
 szArrived db 'Arrived', 0
 szRemoved db 'Removed', 0

DBT_DEVICEARRIVAL        = 8000h
DBT_DEVICEREMOVECOMPLETE = 8004h
DBT_DEVTYP_VOLUME        = 2


I tried this and it doesn't detect any CD inserted or removed.

Is it complete?

Thanks.


threadomancy; 2.) I've fixed your quote/code tags.
Posted on 2010-04-29 21:56:52 by skywalker
Sorry about that.

Andy
Posted on 2010-04-30 10:21:12 by skywalker
Hi

This example Detect USB device insertion
It is the same function DBT_DEVICE

http://www.winasm.net/forum/index.php?act=Attach&type=post&id=17752

Or your can make with IO_Ctl and a Timer


.const
IOCTL_STORAGE_CHECK_VERIFY  equ 002d4800h
IOCTL_STORAGE_CHECK_VERIFY2 equ 002d0800h

invoke GetCDHandle,CTEXT ("\\.\F:")
.if eax !=0
invoke VerifyMedia,hDevice
.if eax==TRUE
invoke SetDlgItemText,hWnd,1003,CTEXT ("CD Found!")
.else
invoke SetDlgItemText,hWnd,1003,CTEXT ("No CD Found!")
jmp @F
.endif

GetCDHandle  proc lpszDevice:DWORD
invoke CreateFile,lpszDevice,GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
    .if eax != INVALID_HANDLE_VALUE
        mov  hDevice,eax
      .else
        mov eax,FALSE
    .endif     
ret
GetCDHandle endp

VerifyMedia Proc _hDevice:DWORD
LOCAL dwBytes:DWORD
invoke DeviceIoControl,_hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0,0, 0, addr dwBytes, 0
.if eax!=0
        mov eax,1
  .else
          mov eax,0
    .endif
    ret
VerifyMedia endp



This is a part of my CD ripper project and is tested.

Greets,
Posted on 2010-05-30 05:27:51 by ragdog