虚拟打印机监视器与Windows7 x64 1722错误

时间:2011-11-19 14:46:05

标签: c++ printing virtual monitor

我想为虚拟打印机应用编写自己的端口监视器。现在我尝试从Winspools.h调用一些函数,但每个func都返回错误代码1722.手动启动后台处理程序和RPCLocator服务没有帮助。这是我的代码:

BOOL Result;

MONITOR_INFO_1 monBuff[256];
memset(&monBuff, 256, sizeof(monBuff));
DWORD capacity;
DWORD returned;

system("net start spooler");
system("net start RPCLocator");

Result = EnumMonitors(NULL, 2, (LPBYTE)monBuff, sizeof(MONITOR_INFO_1)*256,  &capacity, &returned);
if(!Result)
    cout<<"Error: "<<GetLastError()<<" occured.\n";

MONITOR_INFO_2 monInfo;
monInfo.pName = "RedLangMonitor";
monInfo.pEnvironment = "Windows x64";
monInfo.pDLLName = "RedLangMonSrv.dll";

Result = AddMonitor(NULL, 2, (LPBYTE)&monInfo);
if(!Result)
    cout<<"Error: "<<GetLastError()<<" occured.\n";

Result = AddPort(NULL, NULL, "RedLangMonitor");
if(!Result)
    cout<<"Error: "<<GetLastError()<<" occured.\n";

请为我提供一些解决方案来实现这一目标。

1 个答案:

答案 0 :(得分:0)

有些奇怪,但重启2次后问题就消失了。我知道,那不是神秘主义者,但我没有时间去寻找这种奇怪行为的原因。