테이프 장치에 대한 정보를 얻어와야 하는 일이 생겼다.
다음 링크를 정독하고 이 아티클을 완성시키도록 하자.
http://msdn2.microsoft.com/en-us/library/aa362558(VS.85).aspx
========================================================================
테이프 장치에 대한 정보 및 제어
아래와 같이 하면 장치 정보와 카트리지(미디어) 정보를 얻을 수 있다.
물론 관련 함수를 쓰면 쓰고 읽기 까지 가능하다.
필자는 미디어 정보만 얻어오고 쓰고 읽는 것은 DBMS에게 맡기므로 넘어가도록 한다.
(테이프 읽고 쓰기 프로그램을 만드시는 분은 MSDN에서 아래 함수나 구조체 중 하나로 찾으면 나옵니다.)
HANDLE hTape; // handle to tape device
DWORD nResult;
TAPE_GET_MEDIA_PARAMETERS tapeMediaInfo;
TAPE_GET_DRIVE_PARAMETERS tapeDriveInfo;
hTape = CreateFile(TEXT("\\\\.\\TAPE0"), // tape dev to open
GENERIC_READ | GENERIC_WRITE, // read/write access
0, // not used
0, // not used
OPEN_EXISTING, // req for tape devs
0, // not used
NULL); // not used
//nResult = PrepareTape(hTape, 1, FALSE);
DWORD size;
/*
ERROR_BEGINNING_OF_MEDIA
1102L
An attempt to access data before the beginning-of-medium marker failed.
ERROR_BUS_RESET
1111L
A reset condition was detected on the bus.
ERROR_DEVICE_NOT_PARTITIONED
1107L
The partition information could not be found when a tape was being loaded.
ERROR_END_OF_MEDIA
1100L
The end-of-tape marker was reached during an operation.
ERROR_FILEMARK_DETECTED
1101L
A filemark was reached during an operation.
ERROR_INVALID_BLOCK_LENGTH
1106L
The block size is incorrect on a new tape in a multivolume partition.
ERROR_MEDIA_CHANGED
1110L
The tape that was in the drive has been replaced or removed.
ERROR_NO_DATA_DETECTED
1104L
The end-of-data marker was reached during an operation.
ERROR_NO_MEDIA_IN_DRIVE
1112L
There is no media in the drive.
ERROR_NOT_SUPPORTED
50L
The tape driver does not support a requested function.
ERROR_PARTITION_FAILURE
1105L
The tape could not be partitioned.
ERROR_SETMARK_DETECTED
1103L
A setmark was reached during an operation.
ERROR_UNABLE_TO_LOCK_MEDIA
1108L
An attempt to lock the ejection mechanism failed.
ERROR_UNABLE_TO_UNLOAD_MEDIA
1109L
An attempt to unload the tape failed.
ERROR_WRITE_PROTECT
19L
The media is write protected
ERROR_DEVICE_REINITIALIZATION_NEEDED
1164L
The indicated device requires reinitialization due to hardware errors.
ERROR_DEVICE_REQUIRES_CLEANING
1165L
ERROR_DEVICE_NOT_CONNECTED
1167L
*/
nResult = GetTapeParameters(hTape, GET_TAPE_MEDIA_INFORMATION, &size, (LPVOID)&tapeMediaInfo);
nResult = GetTapeParameters(hTape, GET_TAPE_DRIVE_INFORMATION, &size, (LPVOID)&tapeDriveInfo);
생각보다 쉬웠다. 이넘땜에 WMI까지 해봤는데
결국 기본 라이브러리에 포함되어 있다니.. OTL
'Programming > MFC' 카테고리의 다른 글
ADO 객체 정리 (0) | 2008.11.12 |
---|---|
버그 트랩 (0) | 2008.04.02 |
[스크랩] IP Helper API를 사용해서 Ethernet Card 정보 알아내기 (0) | 2007.04.13 |