Of course, the above-mentioned answer is correct but if you are using Windows API in C# to check the Print Job Status, you have to do a little bit more, specifically to get rid of nested if-then-else clauses. Here is a sample code:
namespace Sample
{
class UsingNativeAPIs
{
private const int JOB_STATUS_RETAINED = 8192;
private const int JOB_STATUS_COMPLETE = 4096;
private const int JOB_STATUS_RESTART = 2048;
private const int JOB_STATUS_USER_INTERVENTION = 1024;
private const int JOB_STATUS_BLOCKED_DEVQ = 512;
private const int JOB_STATUS_DELETED = 256;
private const int JOB_STATUS_PRINTED = 128;
private const int JOB_STATUS_PAPEROUT = 64;
private const int JOB_STATUS_OFFLINE = 32;
private const int JOB_STATUS_PRINTING = 16;
private const int JOB_STATUS_SPOOLING = 8;
private const int JOB_STATUS_DELETING = 4;
private const int JOB_STATUS_ERROR = 2;
private const int JOB_STATUS_PAUSED = 1;
private Dictionary<int, string> jDict = new Dictionary<int, string>()
{
{JOB_STATUS_RETAINED, "Retained"},
{JOB_STATUS_COMPLETE, "Complete"},
{JOB_STATUS_RESTART, "restarted"},
{JOB_STATUS_USER_INTERVENTION, "UserIntervention"},
{JOB_STATUS_BLOCKED_DEVQ, "Blocked"},
{JOB_STATUS_DELETED, "Deleted"},
{JOB_STATUS_PRINTED, "Printed"},
{JOB_STATUS_PAPEROUT, "PaperOut"},
{JOB_STATUS_OFFLINE, "Offline"},
{JOB_STATUS_PRINTING, "Printing"},
{JOB_STATUS_SPOOLING, "Spooling"},
{JOB_STATUS_DELETING, "Deleting"},
{JOB_STATUS_ERROR, "Error"},
{JOB_STATUS_PAUSED, "Paused"},
};
private StringBuilder Get_Status(JOB_INFO_2W[] jobInfos, /*... your parameters, if any*/)
{
string jobStatus;
StringBuilder sb;
foreach (var job in jobInfos)
{
jobStatus = "";
foreach (var item in jdict)
{
if ((job.Status & item.Key) == item.Key)
{
jobStatus = item.Value;
break; // or just ignore this line if you look for all combined statuses
}
}
sb.Append("Status = " + jobStatus);
}
return sb;
}
}
}