1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| const std::string html = ...; // берём из ресурсов
if (html.empty())
return;
char tempPath[MAX_PATH], filePath[MAX_PATH];
GetTempPath(MAX_PATH, tempPath);
GetTempFileName(tempPath, "htm", 0, filePath);
HANDLE handle = CreateFile(filePath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (handle)
{
DWORD dwBytesWritten;
WriteFile(handle, html.c_str(), html.length(), &dwBytesWritten, 0);
CloseHandle(handle);
// меняем значение реестра (IE хранит настройки для колонтитулов в нём)
// ...
// отправляем файл на печать
const std::string printCmd = std::string("mshtml.dll,PrintHTML \"") + filePath + "\"";
ShellExecute(0, NULL, "rundll32.exe", printCmd.c_str(), NULL, SW_NORMAL);
} |