forked from 0x00-0x00/zeroday-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriggerXPSPrint.cpp
More file actions
23 lines (22 loc) · 824 Bytes
/
TriggerXPSPrint.cpp
File metadata and controls
23 lines (22 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Triggers the XPS printer by creating a print job - @OneLogicalMyth
// Compile with /MT
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
#include <xpsobjectmodel.h>
#include <xpsprint.h>
using namespace std;
#pragma comment(lib, "xpsprint.lib")
#pragma warning( disable : 4995 )
int main()
{
CoInitialize(nullptr);
IXpsOMObjectFactory *xpsFactory = NULL;
CoCreateInstance(__uuidof(XpsOMObjectFactory), NULL, CLSCTX_INPROC_SERVER, __uuidof(IXpsOMObjectFactory), reinterpret_cast<LPVOID*>(&xpsFactory));
HANDLE completionEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
IXpsPrintJob *job = NULL;
IXpsPrintJobStream *jobStream = NULL;
StartXpsPrintJob(L"Microsoft XPS Document Writer", L"Print Job 1", NULL, NULL, completionEvent, NULL, 0, &job, &jobStream, NULL);
jobStream->Close();
CoUninitialize();
}