Блокировка и разблокировка CD-ROM

Советы » CD-ROM » Блокировка и разблокировка CD-ROM

Вы уж простите, что на сях... сподручней было :

//заблокировать 
void

CMFcDlg::OnBnClickedButton1() { HANDLE hDevice = CreateFile ("\\.\E:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL); DWORD dwBytesReturned = 0; PREVENT_MEDIA_REMOVAL pmr = {TRUE}; if(!DeviceIoControl (hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &pmr, sizeof(pmr), NULL, 0, &dwBytesReturned, NULL)) AfxMessageBox ("Door can't be locked"); CloseHandle (hDevice); } //разблокировать void

CMFcDlg::OnBnClickedButton2() { HANDLE hDevice = CreateFile ("\\.\E:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL); DWORD dwBytesReturned = 0; PREVENT_MEDIA_REMOVAL pmr = {FALSE}; if(!DeviceIoControl (hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &pmr, sizeof(pmr), NULL, 0, &dwBytesReturned, NULL)) AfxMessageBox ("Door can't be unlocked"); CloseHandle (hDevice); }

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com