From 645d909b28b29970af220d5d241ac8b5c5add38e Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Wed, 10 Jun 2020 13:31:36 +0800 Subject: [PATCH] prntvpt: Implement PTOpenProviderEx. Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/prntvpt/Makefile.in | 4 +++- dlls/prntvpt/main.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/dlls/prntvpt/Makefile.in b/dlls/prntvpt/Makefile.in index 5efd1c4eb26..a3db8760c29 100644 --- a/dlls/prntvpt/Makefile.in +++ b/dlls/prntvpt/Makefile.in @@ -1,4 +1,6 @@ -MODULE = prntvpt.dll +MODULE = prntvpt.dll +IMPORTLIB = prntvpt +IMPORTS = winspool EXTRADLLFLAGS = -mno-cygwin diff --git a/dlls/prntvpt/main.c b/dlls/prntvpt/main.c index ec7cf7c3e2e..902be871147 100644 --- a/dlls/prntvpt/main.c +++ b/dlls/prntvpt/main.c @@ -22,11 +22,20 @@ #include "windef.h" #include "winbase.h" +#include "wingdi.h" +#include "winspool.h" #include "prntvpt.h" +#include "wine/heap.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(prntvpt); +struct prn_provider +{ + DWORD owner; + HANDLE hprn; +}; + BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { TRACE("(%p, %d, %p)\n", hinst, reason, reserved); @@ -42,7 +51,6 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) return TRUE; } - HRESULT WINAPI PTQuerySchemaVersionSupport(PCWSTR printer, DWORD *version) { FIXME("stub:%s %p\n", debugstr_w(printer), version); @@ -57,6 +65,25 @@ HRESULT WINAPI PTOpenProvider(PCWSTR printer, DWORD version, HPTPROVIDER *provid HRESULT WINAPI PTOpenProviderEx(const WCHAR *printer, DWORD max_version, DWORD pref_version, HPTPROVIDER *provider, DWORD *used_version) { - FIXME("%s, %d, %d, %p, %p: stub\n", debugstr_w(printer), max_version, pref_version, provider, used_version); - return E_NOTIMPL; + struct prn_provider *prov; + + TRACE("%s, %d, %d, %p, %p\n", debugstr_w(printer), max_version, pref_version, provider, used_version); + + if (!max_version || !provider || !used_version) + return E_INVALIDARG; + + prov = heap_alloc(sizeof(*prov)); + if (!prov) return E_OUTOFMEMORY; + + if (!OpenPrinterW((LPWSTR)printer, &prov->hprn, NULL)) + { + heap_free(prov); + return HRESULT_FROM_WIN32(GetLastError()); + } + + prov->owner = GetCurrentThreadId(); + *provider = (HPTPROVIDER)prov; + *used_version = 1; + + return S_OK; }