d3drm/tests: Spelling fixes for a couple of ok() messages.
[wine.git] / dlls / ntprint / ntprint.c
blobb6d77b36840525b616855a9f7d7e0c23838ce4a7
1 /*
2 * Implementation of the Spooler Setup API (Printing)
4 * Copyright 2007 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28 #include "wingdi.h"
29 #include "winnls.h"
30 #include "winver.h"
31 #include "winspool.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(ntprint);
38 typedef struct {
39 LPMONITOR_INFO_2W mi2; /* Buffer for installed Monitors */
40 DWORD installed; /* Number of installed Monitors */
41 } monitorinfo_t;
43 /*****************************************************
44 * DllMain
46 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
48 TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
50 switch(fdwReason)
52 case DLL_WINE_PREATTACH:
53 return FALSE; /* prefer native version */
55 case DLL_PROCESS_ATTACH:
56 DisableThreadLibraryCalls( hinstDLL );
57 break;
59 return TRUE;
62 /*****************************************************
63 * PSetupCreateMonitorInfo [NTPRINT.@]
68 HANDLE WINAPI PSetupCreateMonitorInfo(LPVOID unknown1, LPVOID unknown2,LPVOID unknown3)
70 monitorinfo_t * mi=NULL;
71 DWORD needed;
72 DWORD res;
74 TRACE("(%p, %p, %p)\n", unknown1, unknown2, unknown3);
76 if ((unknown2 != NULL) || (unknown3 != NULL)) {
77 FIXME("got unknown parameter: (%p, %p, %p)\n", unknown1, unknown2, unknown3);
78 return NULL;
81 mi = HeapAlloc(GetProcessHeap(), 0, sizeof(monitorinfo_t));
82 if (!mi) {
83 /* FIXME: SetLastError() needed? */
84 return NULL;
87 /* Get the needed size for all Monitors */
88 res = EnumMonitorsW(NULL, 2, NULL, 0, &needed, &mi->installed);
89 if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
90 mi->mi2 = HeapAlloc(GetProcessHeap(), 0, needed);
91 res = EnumMonitorsW(NULL, 2, (LPBYTE) mi->mi2, needed, &needed, &mi->installed);
94 if (!res) {
95 HeapFree(GetProcessHeap(), 0, mi);
96 /* FIXME: SetLastError() needed? */
97 return NULL;
100 TRACE("=> %p (%u monitors installed)\n", mi, mi->installed);
101 return mi;
104 /*****************************************************
105 * PSetupDestroyMonitorInfo [NTPRINT.@]
109 VOID WINAPI PSetupDestroyMonitorInfo(HANDLE monitorinfo)
111 monitorinfo_t * mi = monitorinfo;
113 TRACE("(%p)\n", mi);
114 if (mi) {
115 if (mi->installed) HeapFree(GetProcessHeap(), 0, mi->mi2);
116 HeapFree(GetProcessHeap(), 0, mi);
120 /*****************************************************
121 * PSetupEnumMonitor [NTPRINT.@]
123 * Copy the selected Monitorname to a buffer
125 * PARAMS
126 * monitorinfo [I] HANDLE from PSetupCreateMonitorInfo
127 * index [I] Nr. of the Monitorname to copy
128 * buffer [I] Target, that receive the Monitorname
129 * psize [IO] PTR to a DWORD that hold the size of the buffer and receive
130 * the needed size, when the buffer is too small
132 * RETURNS
133 * Success: TRUE
134 * Failure: FALSE
136 * NOTES
137 * size is in Bytes on w2k and WCHAR on XP
141 BOOL WINAPI PSetupEnumMonitor(HANDLE monitorinfo, DWORD index, LPWSTR buffer, LPDWORD psize)
143 monitorinfo_t * mi = monitorinfo;
144 LPWSTR nameW;
145 DWORD len;
147 TRACE("(%p, %u, %p, %p) => %d\n", mi, index, buffer, psize, psize ? *psize : 0);
149 if (index < mi->installed) {
150 nameW = mi->mi2[index].pName;
151 len = lstrlenW(nameW) + 1;
152 if (len <= *psize) {
153 memcpy(buffer, nameW, len * sizeof(WCHAR));
154 TRACE("#%u: %s\n", index, debugstr_w(buffer));
155 return TRUE;
157 *psize = len;
158 SetLastError(ERROR_INSUFFICIENT_BUFFER);
159 return FALSE;
161 SetLastError(ERROR_NO_MORE_ITEMS);
162 return FALSE;