关于打印信息监控的问题,请各位帮忙!!! 是想控制自己的打印信息,还是要去监控打印机?获取所有要打印的信息(包括其他用户的打印)? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是去监控打印机,不过是本机的打印机.也要监控通过网络在本机的打印信息. using System;using System.Data;using System.Runtime.InteropServices;namespace EnumPrintjobstest{ class Class1 { [DllImport("winspool.drv",CharSet=CharSet.Auto)] static extern bool OpenPrinter(string name,out IntPtr hPrinter, IntPtr pDefault); [DllImport("winspool.drv",CharSet=CharSet.Auto)] static extern bool ClosePrinter(IntPtr hPrinter);// BOOL EnumJobs(// HANDLE hPrinter, // handle to printer object// DWORD FirstJob, // index of first job// DWORD NoJobs, // number of jobs to enumerate// DWORD Level, // information level// LPBYTE pJob, // job information buffer// DWORD cbBuf, // size of job information buffer// LPDWORD pcbNeeded, // bytes received or required// LPDWORD pcReturned // number of jobs received// ); [DllImport("winspool.drv",CharSet=CharSet.Auto)]// static extern bool EnumJobs(IntPtr hPrinter,int FirstJob,int NoJobs,int Level,out IntPtr pJob,int cbBuf,out int pcbNeeded,out int pcReturned); static extern bool EnumJobs(IntPtr hPrinter,int FirstJob,int NoJobs,int Level,out IntPtr pJob,int cbBuf,out IntPtr pcbNeeded,out IntPtr pcReturned); [STAThread] static void Main(string[] args) { string PrintName="\\"+"\\"+"FRANK"+"\\"+"Epson LQ"; EnumJobs(PrintName); // Console.Write(PrintName.ToString()); string str=Console.ReadLine(); } private static void EnumJobs(string StrPrintName) { bool bRet; int cbBuf=0; IntPtr pPrintHand= IntPtr.Zero; IntPtr Pdef= IntPtr.Zero; IntPtr pJob=IntPtr.Zero;// int dwNeeded,dwReturned; IntPtr dwNeeded,dwReturned; bRet = OpenPrinter(StrPrintName, out pPrintHand, Pdef); Console.Write("PrintName:{0}\n",StrPrintName); //ok Console.Write("PrintHand:{0}\n",pPrintHand); //ok if (bRet) { if( ! EnumJobs( pPrintHand, 0, 256,1,out pJob , 0, out dwNeeded,out dwReturned ) ) { Console.Write("dwNeeded {0}",dwNeeded); //ok Console.Write("dwReturned {0}",dwReturned); //error ?// ...... } } else { ClosePrinter(pPrintHand); Console.Write("PrintName error"); } ClosePrinter(pPrintHand); } } WinForm开发时如何调试窗口 请教一个问题 关于C# winform 里listview控件的 System.FormatException: 该字符串未被识别为有效的 DateTime 一个简单的小程序,那位高手帮忙做一下,或者提供下现成的,小弟愿意付酬劳 .net中调用Word出错 关于输入輸出問題 C#解答 求基于ftp协议的实现不同用户登录ftp系统,并实现匿名登录 请问高手关于Remoting的一个问题? VS 调试 附加到进程 中找不到对应项的问题 Dataset中表的字段数问題 windows服务安装出错的问题!! 请教: checkedListBox 多选取值的问题!!
using System.Data;
using System.Runtime.InteropServices;namespace EnumPrintjobstest
{
class Class1
{
[DllImport("winspool.drv",CharSet=CharSet.Auto)]
static extern bool OpenPrinter(string name,out IntPtr hPrinter, IntPtr pDefault); [DllImport("winspool.drv",CharSet=CharSet.Auto)]
static extern bool ClosePrinter(IntPtr hPrinter);// BOOL EnumJobs(
// HANDLE hPrinter, // handle to printer object
// DWORD FirstJob, // index of first job
// DWORD NoJobs, // number of jobs to enumerate
// DWORD Level, // information level
// LPBYTE pJob, // job information buffer
// DWORD cbBuf, // size of job information buffer
// LPDWORD pcbNeeded, // bytes received or required
// LPDWORD pcReturned // number of jobs received
// );
[DllImport("winspool.drv",CharSet=CharSet.Auto)]
// static extern bool EnumJobs(IntPtr hPrinter,int FirstJob,int NoJobs,int Level,out IntPtr pJob,int cbBuf,out int pcbNeeded,out int pcReturned);
static extern bool EnumJobs(IntPtr hPrinter,int FirstJob,int NoJobs,int Level,out IntPtr pJob,int cbBuf,out IntPtr pcbNeeded,out IntPtr pcReturned); [STAThread]
static void Main(string[] args)
{
string PrintName="\\"+"\\"+"FRANK"+"\\"+"Epson LQ";
EnumJobs(PrintName);
// Console.Write(PrintName.ToString());
string str=Console.ReadLine();
} private static void EnumJobs(string StrPrintName)
{
bool bRet;
int cbBuf=0;
IntPtr pPrintHand= IntPtr.Zero;
IntPtr Pdef= IntPtr.Zero;
IntPtr pJob=IntPtr.Zero;
// int dwNeeded,dwReturned;
IntPtr dwNeeded,dwReturned;
bRet = OpenPrinter(StrPrintName, out pPrintHand, Pdef);
Console.Write("PrintName:{0}\n",StrPrintName); //ok
Console.Write("PrintHand:{0}\n",pPrintHand); //ok if (bRet)
{
if( ! EnumJobs( pPrintHand, 0, 256,1,out pJob , 0, out dwNeeded,out dwReturned ) )
{
Console.Write("dwNeeded {0}",dwNeeded); //ok
Console.Write("dwReturned {0}",dwReturned); //error ?
// ......
} }
else
{
ClosePrinter(pPrintHand);
Console.Write("PrintName error");
}
ClosePrinter(pPrintHand);
}
}