mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 13:13:00 +00:00
[PRINTING]
Finally merge my branch "colins-printing-for-freedom", giving us an initial implementation of a Win32-compatible Printing Stack (localmon, localspl, spoolss, spoolsv, winspool) You can now send raw data to parallel port printers using documented Win32 API. An example application is in my "winspool_print" commandline tool merged to rosapps. ReactOS folks, thanks for your support during the development of this, making my bachelor's thesis a reality! :) Documentation/Thesis: https://svn.reactos.org/reactos/trunk/documentation/articles/Printing%20Stack%20Thesis/thesis.pdf Video: https://www.youtube.com/watch?v=cNzePucTOLY CORE-10489 svn path=/trunk/; revision=73039
This commit is contained in:
commit
fcaeb4d6a4
198 changed files with 19930 additions and 10031 deletions
|
@ -5,4 +5,5 @@ add_subdirectory(ntfsinfo)
|
|||
add_subdirectory(tee)
|
||||
add_subdirectory(touch)
|
||||
add_subdirectory(uptime)
|
||||
add_subdirectory(winspool_print)
|
||||
add_subdirectory(y)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
add_executable(winspool_print main.c)
|
||||
set_module_type(winspool_print win32cui)
|
||||
add_importlibs(winspool_print winspool msvcrt kernel32)
|
||||
add_cd_file(TARGET winspool_print DESTINATION reactos/system32 FOR all)
|
76
rosapps/applications/cmdutils/winspool_print/main.c
Normal file
76
rosapps/applications/cmdutils/winspool_print/main.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int ReturnValue = 1;
|
||||
DWORD dwRead;
|
||||
DWORD dwWritten;
|
||||
HANDLE hFile = INVALID_HANDLE_VALUE;
|
||||
HANDLE hPrinter = NULL;
|
||||
DOC_INFO_1W docInfo;
|
||||
BYTE Buffer[20000];
|
||||
|
||||
hFile = CreateFileW(L"testfile", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("CreateFileW failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!ReadFile(hFile, Buffer, sizeof(Buffer), &dwRead, NULL))
|
||||
{
|
||||
printf("ReadFile failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!OpenPrinterW(L"Dummy Printer On LPT1", &hPrinter, NULL))
|
||||
{
|
||||
printf("OpenPrinterW failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
ZeroMemory(&docInfo, sizeof(docInfo));
|
||||
docInfo.pDocName = L"winspool_print";
|
||||
|
||||
if (!StartDocPrinterW(hPrinter, 1, (LPBYTE)&docInfo))
|
||||
{
|
||||
printf("StartDocPrinterW failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!StartPagePrinter(hPrinter))
|
||||
{
|
||||
printf("StartPagePrinter failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!WritePrinter(hPrinter, Buffer, dwRead, &dwWritten))
|
||||
{
|
||||
printf("WritePrinter failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!EndPagePrinter(hPrinter))
|
||||
{
|
||||
printf("EndPagePrinter failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!EndDocPrinter(hPrinter))
|
||||
{
|
||||
printf("EndDocPrinter failed, last error is %lu!\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
ReturnValue = 0;
|
||||
|
||||
Cleanup:
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(hFile);
|
||||
|
||||
if (hPrinter)
|
||||
ClosePrinter(hPrinter);
|
||||
|
||||
return ReturnValue;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue