TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mary
NA
5
0
Get printer status before sending a job with C#
Aug 10 2011 5:06 AM
I've an application the needs to query the state of a printer before attempting to send it anything.if catch error out of paper or low paper and etc i can detect them.
but following code always return result to Ready when printer is no paper.
oManagementScope = new ManagementScope(ManagementPath.DefaultPath);
oManagementScope.Connect();
string sPrinterName = comboBox1.SelectedItem.ToString();
SelectQuery oSelectQuery = new SelectQuery();
oSelectQuery.QueryString = @"SELECT * FROM Win32_Printer WHERE Name = '" +
sPrinterName.Replace("\\", "\\\\") + "'";
ManagementObjectSearcher oObjectSearcher =new ManagementObjectSearcher(oManagementScope, oSelectQuery);
ManagementObjectCollection oObjectCollection = oObjectSearcher.Get();
foreach (ManagementObject MObj in oObjectCollection)
{
string myString = MObj["PrinterStatus"].ToString();
Int32 dStatus = Convert.ToInt32(myString);
label1.Text = printerStatus[dStatus];
}
thanks
Reply
Answers (
1
)
Help creating a loop
Opening a form by clicking the button in another form