Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[7747] 프린터 상태 체크법은?
이상탁 [] 2593 읽음    2001-12-13 17:17
윈도우 98과 2000 에서 기본프린터의 상태를 체크하기 위해서 다음과 같이 했는데,
pPrinterInfo.status 값이 항상 0 으로 나옵니다.

프린터의 등록정보에서 "인쇄일시 중지","인쇄 잠깐 멈춤" 을 하면 status 값이 1이 나옵니다.(윈98/윈2000 동일)

윈98에서의 직접 프린터 인터럽트를 통해 확인(어셈블리 이용)하는 tip이 있었지만(이것도 잘 작동되지 않음), 윈2000과 공용으로 사용하고 싶어 이렇게 API 를 사용해서 만들려고 했는데 되질 않터군요. 실제 인쇄를 하면서 체크해야 되는 건지도.....

윈2000 과 윈98에서 공용으로 프린터의 상태를 체크할 수 있는 방법에 대해서 조언을 해 주시거나 아래 소스를 수정해 주셨으면 합니다.

감사합니다.


var
device : array [0..CCHDEVICENAME -1 ] of char;
driver : array [0..(MAX_PATH)] of char;
port : array [0..32] of char;
handle : Thandle;
hmode : Thandle;
CByteNeeded :integer;
CByteUsed : integer;
pPrinterInfo : ^Tprinterinfo2;
statstr : string;
begin
handle := 0;

printer.printerindex := -1;
printer.GetPrinter(device, driver, port, hmode);

if openprinter(device, handle, nil) = false then
    exit;

//cByteNeeded 가져오기
if Getprinter(Handle, 2, nil, 0, addr(CByteNeeded)) = false then
    if getlasterror() <> ERROR_INSUFFICIENT_BUFFER then
       exit;

Getmem( pPrinterInfo, CByteneeded);
//프린터의 정보가져오기
if Getprinter( handle, 2, pPrinterInfo, cByteNeeded, addr(CByteUsed)) = false then
    if getlasterror() <> ERROR_INSUFFICIENT_BUFFER then begin
       Freemem(pPrinterInfo);
       Exit;
    end;

//pPrinterInfo 에 현재 프린터의 상태가 넘어옵니다.
//pPrinterInfo.status에 현재 프린터의 상태값이 옵니다.
//status값은 아래값들을 참조하시고요
// 더자세한 사항은 win32.hlp에서 printer_info_2를 참고하시면 될겁니다.

//이부분에 pPrinterInfo.status를 check하는 부분이 들어가면 되겠지요

//  showmessage(pPrinterInfo.pPrinterName+' '+inttostr(pPrinterInfo.AveragePPM));

case pPrinterInfo.Status of
    PRINTER_STATUS_BUSY :
       statstr := 'PRINTER_STATUS_BUSY';
    PRINTER_STATUS_DOOR_OPEN :
       statstr := 'PRINTER_STATUS_DOOR_OPEN';
    PRINTER_STATUS_ERROR :
       statstr := 'PRINTER_STATUS_ERROR';
    PRINTER_STATUS_INITIALIZING :
       statstr := 'PRINTER_STATUS_INITIALIZING';
    PRINTER_STATUS_IO_ACTIVE :
       statstr := 'PRINTER_STATUS_IO_ACTIVE';
    PRINTER_STATUS_MANUAL_FEED :
       statstr := 'PRINTER_STATUS_MANUAL_FEED';
    PRINTER_STATUS_NO_TONER :
       statstr := 'PRINTER_STATUS_NO_TONER';
    PRINTER_STATUS_NOT_AVAILABLE :
       statstr := 'PRINTER_STATUS_NOT_AVAILABLE';
    PRINTER_STATUS_OFFLINE :
       statstr := 'PRINTER_STATUS_OFFLINE';
    PRINTER_STATUS_OUT_OF_MEMORY :
       statstr := 'PRINTER_STATUS_OUT_OF_MEMORY';
    PRINTER_STATUS_OUTPUT_BIN_FULL :
       statstr := 'PRINTER_STATUS_OUTPUT_BIN_FULL';
    PRINTER_STATUS_PAGE_PUNT :
       statstr := 'PRINTER_STATUS_PAGE_PUNT';
    PRINTER_STATUS_PAPER_JAM :
       statstr := 'PRINTER_STATUS_PAPER_JAM';
    PRINTER_STATUS_PAPER_OUT :
       statstr := 'PRINTER_STATUS_PAPER_OUT';
    PRINTER_STATUS_PAPER_PROBLEM :
       statstr := 'PRINTER_STATUS_PAPER_PROBLEM';
    PRINTER_STATUS_PAUSED :
       statstr := 'PRINTER_STATUS_PAUSED';
    PRINTER_STATUS_PENDING_DELETION :
       statstr := 'PRINTER_STATUS_PENDING_DELETION';
    PRINTER_STATUS_PRINTING :
       statstr := 'PRINTER_STATUS_PRINTING';
    PRINTER_STATUS_PROCESSING :
       statstr := 'PRINTER_STATUS_PROCESSING';
    PRINTER_STATUS_TONER_LOW :
       statstr := 'PRINTER_STATUS_TONER_LOW';
//     PRINTER_STATUS_UNAVAILABLE :
//        statstr := 'PRINTER_STATUS_UNAVAILABLE';
    PRINTER_STATUS_USER_INTERVENTION :
       statstr := 'PRINTER_STATUS_USER_INTERVENTION';
    PRINTER_STATUS_WAITING :
       statstr := 'PRINTER_STATUS_WAITING';
    PRINTER_STATUS_WARMING_UP :
       statstr := 'PRINTER_STATUS_WARMING_UP';
    PRINTER_STATUS_SERVER_UNKNOWN :
       statstr := 'PRINTER_STATUS_SERVER_UNKNOWN';
    PRINTER_STATUS_POWER_SAVE :
       statstr := 'PRINTER_STATUS_POWER_SAVE';
  else
       statstr := 'PRINTER_STATUS_UNKWON';
  end;

  showmessage(statstr);

  Freemem(pPrinterInfo);

+ -

관련 글 리스트
7747 프린터 상태 체크법은? 이상탁 2593 2001/12/13
7760     답변주실분 없나요?(내용무) 이상탁 705 2001/12/17
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.