printrequest.cpp
来自「window下的多线程编程参考书。值得一读」· C++ 代码 · 共 37 行
CPP
37 行
#include <stdio.h>
#include "CMcl.h"
#define MAX_REQUEST_SIZE (MAX_PATH + 1)
#define PRINT_REQUEST_MAILBOX_NAME __TEXT("MclTestPrintServerMailbox")
int main(int argc, char *argv[]) {
// request that a document be printed by invoking this
// program with the filename as the first command line parameter...
// open the print server mailbox object...
// notice that the mailbox must already exist for this to work...
CMclMailbox m_cmRequests(PRINT_REQUEST_MAILBOX_NAME);
// check the status of the mailbox...
if (m_cmRequests.Status() != NO_ERROR) {
printf( "Unable to open print request mailbox.\n");
return -1;
}
// format a request...
BYTE abRequest[MAX_REQUEST_SIZE];
ZeroMemory( abRequest, MAX_REQUEST_SIZE);
strncpy( (char *) abRequest, argv[1], MAX_REQUEST_SIZE);
// post the request...
if (m_cmRequests.Post( abRequest, INFINITE)) {
printf( "Print request submitted.\n");
}
else {
printf( "Unable to submit print request.\n");
return -1;
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?