Mikael Jansson
asked on
Where are UploadPrinterDriverPackage and InstallPrinterDriverFromPackage in winspool.drv
Hi,
I have searched really hard to find how to call the methods UploadPrinterDriverPackage and InstallPrinterDriverFromPa ckage that are described in the "Printing and Print spooler functions" described on MSDN for Windows GDI. The documentation describes those methods and several other methods that are not found either. It refers to winspool as header and library and I assume that they then should be available in winspool.drv as the other methods described and working.
When I run Dumpbin on winspool.drv I dont find some of the functions described in the documentation on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_7mgj.asp
I am coding from both VB.NET but mainly from C#.NET in VS 2005 and uses many of the existing methods today in winspool.drv
I also have anothor smaller question related to calling e.g. winspool.drv methods, is it unsafe to use this kind of DllImport calls or can a application using this be successfully tested in Microsofts test program within Microsoft Certified partner program?
I really need help from you mega experts out there to solve this (the first question about winspool methods).
br
/ Mikael
I have searched really hard to find how to call the methods UploadPrinterDriverPackage
When I run Dumpbin on winspool.drv I dont find some of the functions described in the documentation on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_7mgj.asp
I am coding from both VB.NET but mainly from C#.NET in VS 2005 and uses many of the existing methods today in winspool.drv
I also have anothor smaller question related to calling e.g. winspool.drv methods, is it unsafe to use this kind of DllImport calls or can a application using this be successfully tested in Microsofts test program within Microsoft Certified partner program?
I really need help from you mega experts out there to solve this (the first question about winspool methods).
br
/ Mikael
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
These functions are not properly exported in the Winspool.drv, you can use LoadLibrary() and GetProcAddress() to get hold of those functions. Here is a sample code you can use:
#include "Winspool.h"
typedef HRESULT (*LPUploadPrinterDriverPac kage)(
LPCTSTR pszServer,
LPCTSTR pszInfPath,
LPCTSTR pszEnvironment,
DWORD dwFlags,
HWND hwnd,
LPTSTR pszDestInfPath,
PULONG pcchDestInfPath
);
typedef HRESULT (*LPInstallPrinterDriverFr omPackage) (
LPCTSTR pszServer,
LPCTSTR pszInfPath,
LPCTSTR pszDriverName,
LPCTSTR pszEnvironment,
DWORD dwFlags
);
DWORD MyInstallDriver(HWND hwnd)
{
TCHAR szDestInfPath[MAX_PATH*2 + 1];
DWORD dwDestLen = MAX_PATH*2;
LPUploadPrinterDriverPacka ge pUploadPackage = NULL;
HINSTANCE hInstance = ::LoadLibrary(_TEXT("Winsp ool.drv")) ;
pUploadPackage = (LPUploadPrinterDriverPack age)GetPro cAddress(h Instance, "UploadPrinterDriverPackag eW");
if(pUploadPackage==NULL)
return 0L;
HRESULT lResult = pUploadPackage(
NULL,
_TEXT("MyDriver.inf"),
_TEXT("Windows NT x86"),
UPDP_SILENT_UPLOAD | UPDP_UPLOAD_ALWAYS,
hwnd,
szDestInfPath,
&dwDestLen
);
LPInstallPrinterDriverFrom Package pInstallPackage = NULL;
pInstallPackage = (LPInstallPrinterDriverFro mPackage)G etProcAddr ess(hInsta nce, "InstallPrinterDriverFromP ackageW");
if(pInstallPackage!=NULL)
{
lResult = pInstallPackage(NULL,
szDestInfPath,
_TEXT("My Driver Name"),
_TEXT("Windows NT x86"),
IPDFP_COPY_ALL_FILES
);
}
FreeLibrary(hInstance);
return (DWORD)lResult;
}
#include "Winspool.h"
typedef HRESULT (*LPUploadPrinterDriverPac
LPCTSTR pszServer,
LPCTSTR pszInfPath,
LPCTSTR pszEnvironment,
DWORD dwFlags,
HWND hwnd,
LPTSTR pszDestInfPath,
PULONG pcchDestInfPath
);
typedef HRESULT (*LPInstallPrinterDriverFr
LPCTSTR pszServer,
LPCTSTR pszInfPath,
LPCTSTR pszDriverName,
LPCTSTR pszEnvironment,
DWORD dwFlags
);
DWORD MyInstallDriver(HWND hwnd)
{
TCHAR szDestInfPath[MAX_PATH*2 + 1];
DWORD dwDestLen = MAX_PATH*2;
LPUploadPrinterDriverPacka
HINSTANCE hInstance = ::LoadLibrary(_TEXT("Winsp
pUploadPackage = (LPUploadPrinterDriverPack
if(pUploadPackage==NULL)
return 0L;
HRESULT lResult = pUploadPackage(
NULL,
_TEXT("MyDriver.inf"),
_TEXT("Windows NT x86"),
UPDP_SILENT_UPLOAD | UPDP_UPLOAD_ALWAYS,
hwnd,
szDestInfPath,
&dwDestLen
);
LPInstallPrinterDriverFrom
pInstallPackage = (LPInstallPrinterDriverFro
if(pInstallPackage!=NULL)
{
lResult = pInstallPackage(NULL,
szDestInfPath,
_TEXT("My Driver Name"),
_TEXT("Windows NT x86"),
IPDFP_COPY_ALL_FILES
);
}
FreeLibrary(hInstance);
return (DWORD)lResult;
}
ASKER
Thanx for you eagle eyes :-) . My eyes was reading included in XP etc..... sometimes even the brain gets blind ;-)
thanks, you just saved me from searching on something thats not even there!
p.s. Maybe you know another way to solve this before vista?
/ Mikael