{"id":191,"date":"2008-05-01T19:13:11","date_gmt":"2008-05-01T19:13:11","guid":{"rendered":"http:\/\/6teen.ru\/?p=62"},"modified":"2008-05-01T19:13:11","modified_gmt":"2008-05-01T19:13:11","slug":"4537","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=191","title":{"rendered":"\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0430"},"content":{"rendered":"<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0430<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0430\n\n****************************************************************\n\u041a\u0432\u044d\u043d\u0434\u0438:\n\nprocedure TForm32.CD_Lock(Locked: Boolean; DriveLetter: string);\nconst\nIOCTL_STORAGE_MEDIA_REMOVAL = $002D4804;\nvar\nhDrive: THandle;\nReturned: DWORD;\nDisableEject: boolean;\nbegin\nhDrive := CreateFile(PChar('\\\\.\\' + DriveLetter), GENERIC_READ,\n  FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);\nif GetLastError <> 0 then\n  MessageDlg('Error:' + IntToStr(GetLastError), mtError, [mbOK], 0);\ntry\n  DisableEject := Locked;\n  if not DeviceIoControl\n    (hDrive, IOCTL_STORAGE_MEDIA_REMOVAL, \/\/ PREVENT_MEDIA_REMOVAL,\n    @DisableEject, SizeOf(DisableEject), nil, 0, Returned, nil) then\n    MessageDlg('\u041e\u0448\u0438\u0431\u043a\u0430:' + IntToStr(GetLastError), mtError, [mbOK], 0)\nfinally\n  CloseHandle(hDrive)\nend;\nend;\n\nCD_Lock(True) - \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 CD-ROM\nCD_Lock(False) - \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 CD-ROM\n\n**********************************************************\n\n\u0414\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0432\u0435\u0441\u0435\u043b\u044c\u044f \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 CD-ROM\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0447\u0435\u0440\u0435\u0437 \u044d\u0442\u043e:\nprocedure TMainForm.LockCDROMs;\nvar\n  w: dword;\n  Root: string;\n  i: byte;\nbegin\n  w := GetLogicalDrives;\n  Root := '#:\\';\n  for i := 0 to 25 do\n  begin\n    Root[1] := Char(Ord('A') + i);\n    if (W and (1 shl i)) > 0 then\n      if GetDriveType(PChar(Root)) = DRIVE_CDROM then\n      begin\n        DriveLetter := Copy(Root, 1, Length(Root) - 1);\n        CD_Lock(True, DriveLetter)\n      end\n  end;\nend;\n\n*******************************************************************\n\n\u0414\u043b\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043b\u043e\u0442\u043a\u0430 CD-ROM \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f:\n\nfunction LockMedia(ADriveLetter: Char; ALock: Boolean): Boolean;\nvar LWStatus: Hwnd;\n      LTemp: Cardinal;\n      LPMR32: Boolean;\nConst IOCTL_STORAGE_MEDIA_REMOVAL = $2D4804;\nbegin\nLwStatus:=CreateFile(PChar('\\\\.\\' + ADriveLetter + ':'), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0);\nLPMR32:=ALock;\nif LwStatus<>INVALID_HANDLE_VALUE then\nbegin\nresult:=DeviceIoControl(LwStatus, IOCTL_STORAGE_MEDIA_REMOVAL, @LPMR32, sizeof(LPMR32), nil, 0, LTemp, nil);\nCloseHandle(LwStatus);\nend else\nresult := false;\nend;\n\n\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. ADriveLetter - \u0431\u0443\u043a\u0432\u0430 \u0434\u0438\u0441\u043a\u0430, ALock - \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c (true - \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c, false - \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c)\n\n\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:\nLockMedia('d', true);  \/\/ \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0441\u043a D:\nShowMessage('CD-ROM \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d. \u041b\u043e\u0442\u043e\u043a \u043d\u0435 \u0432\u044b\u0435\u0437\u0436\u0430\u0435\u0442.');\nLockMedia('d', false); \/\/ \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0441\u043a D:\nShowMessage('CD-ROM \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d.');\n\n\n\u0410\u0432\u0442\u043e\u0440: Snowy\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0430<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[398,433],"tags":[623,928],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/191"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}