1 /*
2  * PROJECT:     ReactOS Standard Print Processor API Tests
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Main functions
5  * COPYRIGHT:   Copyright 2016 Colin Finck (colin@reactos.org)
6  */
7 
8 #include <apitest.h>
9 
10 #define WIN32_NO_STATUS
11 #include <windef.h>
12 #include <winbase.h>
13 #include <wingdi.h>
14 #include <winspool.h>
15 
16 PVOID
17 GetWinprintFunc(const char* FunctionName)
18 {
19     DWORD cbNeeded;
20     HMODULE hWinprint;
21     PVOID pFunc;
22     WCHAR wszWinprintPath[MAX_PATH];
23 
24     // Build the path to the default Print Processor winprint.dll in the Print Processor directory.
25     if (!GetPrintProcessorDirectoryW(NULL, NULL, 1, (LPBYTE)wszWinprintPath, sizeof(wszWinprintPath), &cbNeeded))
26     {
27         skip("Could not determine the path to the Print Processor directory, last error is %lu!\n", GetLastError());
28         return NULL;
29     }
30 
31     wcscat(wszWinprintPath, L"\\winprint.dll");
32 
33     // Try loading it.
34     hWinprint = LoadLibraryW(wszWinprintPath);
35     if (!hWinprint)
36     {
37         if (GetLastError() != ERROR_MOD_NOT_FOUND)
38         {
39             skip("LoadLibraryW failed for %S with error %lu!\n", wszWinprintPath, GetLastError());
40             return NULL;
41         }
42 
43         // winprint.dll does not exist prior to NT6.
44         // The default Print Processor is implemented in localspl.dll instead.
45         hWinprint = LoadLibraryW(L"localspl.dll");
46         if (!hWinprint)
47         {
48             skip("LoadLibraryW failed for localspl.dll with error %lu!\n", GetLastError());
49             return NULL;
50         }
51     }
52 
53     // Get the function we are looking for.
54     pFunc = GetProcAddress(hWinprint, FunctionName);
55     if (!pFunc)
56     {
57         skip("GetProcAddress failed for %s with error %lu!\n", FunctionName, GetLastError());
58         return NULL;
59     }
60 
61     return pFunc;
62 }
63