<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 5,  comments - 7,  trackbacks - 0

    The following code will allow you to talk to a printer (running on a specific IP Address) to query its current status.

    OLEPRNLib is a COM object that appears to be installed on XP and greater machines.

    On my machine I made a reference on the COM tab of the Add Reference dialog to “oleprn 1.0 Type Library“ which lived in “c:\Windows\System32\oleprn.dll

    using System;
    using OLEPRNLib;
    namespace PrinterStatus
    {
    /// 
     /// Summary description for Class1.
     /// 
     class Class1
    {
    /// 
      /// The main entry point for the application.
      /// 
      [STAThread]
    static void Main(string[] args)
    {
    string[] ErrorMessageText = new string[8];
    ErrorMessageText[0] = "service requested";
    ErrorMessageText[1] = "offline";
    ErrorMessageText[2] = "paper jammed";
    ErrorMessageText[3] = "door open";
    ErrorMessageText[4] = "no toner";
    ErrorMessageText[5] = "toner low";
    ErrorMessageText[6] = "out of paper";
    ErrorMessageText[7] = "low paper";
    int DeviceID = 1;
    int Retries = 1;
    int TimeoutInMS = 2000;
    string CommunityString = "public";
    string IPAddressOfPrinter = "10.3.0.93";
    // Create instance of COM object
       OLEPRNLib.SNMP snmp = new OLEPRNLib.SNMP();
    // Open the SNMP connect to the printer
       snmp.Open(IPAddressOfPrinter, CommunityString, Retries, TimeoutInMS);
    // The actual Warning/Error bits
       uint WarningErrorBits = snmp.GetAsByte(String.Format("25.3.5.1.2.{0}", DeviceID));
    // The actual Status
       uint StatusResult = snmp.GetAsByte(String.Format("25.3.2.1.5.{0}", DeviceID));
    // uint Result2 = snmp.GetAsByte(String.Format("25.3.5.1.1.{0}", DeviceID));
    
    string Result1Str = "";
    switch (StatusResult)
    {
    case 2 : Result1Str = "OK";
    break;
    case 3 : Result1Str = "Warning: ";
    break;
    case 4 : Result1Str = "Being Tested: ";
    break;
    case 5 : Result1Str = "Unavailable for any use: ";
    break;
    default : Result1Str = "Unknown Status Code : "+StatusResult;
    break;
    }
    string Str = "";
    if ((StatusResult == 3 || StatusResult == 5))
    {
    int Mask = 1;
    int NumMsg = 0;
    for (int i=0; i< 8; i++)
    {
    if ((WarningErrorBits & Mask) == Mask)
    {
    if (Str.Length > 0)
    Str += ", ";
    Str += ErrorMessageText[i];
    NumMsg = NumMsg + 1;
    }
    Mask = Mask * 2;
    }
    }
    Console.WriteLine(Result1Str + Str);
    }
    }
    }
    
    posted on Monday, August 08, 2005 8:13 PM | Filed Under [ c# ]

    Comments


    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    Hello.
    I have been talked to a print by this code.
    But I couldn't talk to Zebra Barcode Printer ( 140 Xi III Plus Model ).

    I catched Ready Status and Out of Paper Error, but another status, for example, Printing(Running) and OffLine(Pause) status.

    How can I know these status?
    Posted by Park Jung Sup on 6/20/2007 4:25 PM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    Can you explain me what do "25.3.5.1.2.{0}" mean and what do "25.3.5.1.5.{0}"

    is there any other code like this. if so can me provide the link so that i can know more about SNMP and try to handle/get status information the devices from remote location
    Posted by theertendra on 8/29/2007 11:08 PM

    # re: C# Sample code to talk to a printer using SNMP to get its status.


    The codes that you see are called an OID and basically companies can obtain a private OID. see http://www.alvestrand.no/objectid/

    There are common OID SNMP identifiers and the ones I was using in the article

    The full OID for hrPrinterDetectedErrorState

    .iso.org.dod.internet.mgmt.mib-2.host.hrDevice.hrPrinterTable.hrPrinterEntry.hrPrinterDetectedErrorState

    or simply .1.3.6.1.2.1.25.3.5.1.2

    This object represents any error conditions detected by the printer. The error conditions are encoded as bits in an octet string, with the following

    definitions:
    Condition Bit #
    lowPaper 0
    noPaper 1
    lowToner 2
    noToner 3
    doorOpen 4
    jammed 5
    offline 6
    serviceRequested 7
    inputTrayMissing 8
    outputTrayMissing 9
    markerSupplyMissing 10
    outputNearFull 11
    outputFull 12
    inputTrayEmpty 13
    overduePreventMaint 14

    Bits are numbered starting with the most significant bit of the first byte being bit 0, the least significant bit of the first byte being bit 7, the
    most significant bit of the second byte being bit 8, and so on. A one bit encodes that the condition was detected, while a zero bit encodes that the condition was not detected.

    This object is useful for alerting an operator to specific warning or error conditions that may occur, especially those requiring human intervention.

    The best way to see what is around is to look at a MIB Browser
    http://www.ireasoning.com/mibbrowser.shtml

    If you download the tool above there is a free version and you would then load the Printer-MIB.MIB to get information like above.
    Posted by Chris Crowe on 8/30/2007 4:44 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    My SNMP program is the simple program and write in the C# language. But I faced the problem that I need to type the IP address for my slave before I can get the MIB of my slave, how I can detect my slave's IP address directly without type the IP address? Can you give me some guidelines? Furthermore, I need some coding that write in C# that can show the status for my slaves, such as my slave is on or off. I hope that you can give me some guidelines. Thanks.
    Posted by jelly on 1/12/2008 4:43 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.


    Hi All,

    Can anybody can guide me how can i get all the printer names which are all attached in a Network ?
    Posted by SEN on 5/2/2008 6:46 PM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    nice peace of code, thanks for sharing. unfortunately oleprn.dll isn't documented anywhere...but nevertheless i think i can use it for simple snmp queries.

    seems to me as if you forgot to
    snmp.close();
    after querying.
    Posted by andre on 7/3/2008 11:50 PM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    hi ,
    I need to know whether the printer(dymo label printer) status active or not which was installed on the network (192.168.1.18\dymolabel shared) from the other machine.
    the above example doesent work for me as i cant get the OID for the dymo label printer.
    Can any one help me how to do the above requirement please
    Posted by srinivas on 8/8/2008 2:47 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    after snmp.open at the following code
    uint WarningErrorBits = snmp.GetAsByte(String.Format("25.3.5.1.2.{0}", DeviceID));

    I am getting error "HRESULT E_FAIL has returned from a call to a COM component"
    Can any one help me why I am getting the error!!

    Posted by Ramesh on 9/4/2008 12:19 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    >> I am getting error "HRESULT E_FAIL has returned from a call to a COM component"

    I just got this one too and when pinged it the printer was down.
    Make sure the printer is up.
    Posted by Victor on 10/2/2008 8:14 AM

    # re: java Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    i am going to develop simulator printer,so i need to develop printer mibs for virtual printer to operate them by snmp operation like set,get and trap by specifying oids.
    Posted by vinay on 2/12/2009 3:01 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    hello everyone,
    can anybody guide me to write the code in C# to access the of various node status in LAN using SNMP protocol.If any one is interested please mail me.
    Posted by Sagar Mirajkar on 3/2/2009 3:15 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.


    hai thnks for giving this code to get status . I need more information about Printer like
    1. whether Printer is Printing or not,
    2. whether it is on Or off,
    3.how many copies printed.

    Can u help me
    Posted by XXXXXXX on 3/17/2009 10:18 PM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    hello
    Is it possible to use snmp on network to get informations (counter) from shared printers ?
    Posted by jd on 3/17/2009 10:37 PM

    # re: C# Sample code to talk to a printer using SNMP to get its status.


    ya is it possible
    Posted by XXXXXXX on 3/18/2009 12:20 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.


    can u reply quickly? i need to develop an appliacation controlling printer pls
    Posted by XXXXXXX on 3/18/2009 12:40 AM

    # re: C# Sample code to talk to a printer using SNMP to get its status.

    Gravatar
    you said it is possible to retrieve information from a shared printer (not à network printer) but how.

    for a network printer i send an smtp request to the printer's IP with oid : 1.3.6.1.2.1.43.10.2.1.4.1.1

    but for a shared printer i have to send it to the computer?
    Posted by jd on 3/19/2009 3:55 AM
    posted on 2009-06-18 17:24 Vincent-chen 閱讀(6536) 評論(2)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 自拍日韩亚洲一区在线| 亚洲精品国产精品乱码在线观看| 亚洲AV无码国产丝袜在线观看| 免费看一级高潮毛片| 国产成人aaa在线视频免费观看| 亚洲日韩精品国产3区| 无限动漫网在线观看免费| 国产v亚洲v天堂a无| 青娱乐免费视频在线观看| 亚洲欧洲综合在线| 成人福利免费视频| 亚洲日本VA午夜在线影院| 精品剧情v国产在免费线观看| 一本天堂ⅴ无码亚洲道久久| 处破痛哭A√18成年片免费| 亚洲成熟丰满熟妇高潮XXXXX| 四虎国产精品免费视| xvideos永久免费入口| 亚洲一区二区三区影院 | 欧洲精品码一区二区三区免费看| 午夜dj在线观看免费视频| 欧洲亚洲国产精华液| 亚洲一级Av无码毛片久久精品| 精品97国产免费人成视频| 亚洲色图在线观看| 毛片a级三毛片免费播放| 黄页网址大全免费观看12网站| 国产精品亚洲视频| 99在线免费观看视频| 亚洲精品国产综合久久久久紧| 亚洲日韩在线中文字幕第一页| 久久大香伊焦在人线免费| 国内精品久久久久影院亚洲| 亚洲成av人片一区二区三区| 久久免费公开视频| 亚洲欧洲av综合色无码| 亚洲熟妇无码八AV在线播放| 无码中文在线二区免费| 一级毛片在线完整免费观看| 久久久无码精品亚洲日韩京东传媒| 狠狠久久永久免费观看|