Click here to Skip to main content
15,884,962 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Has any one used the following windows API

C++
HRESULT UploadPrinterDriverPackage(
  _In_     LPCTSTR pszServer,
  _In_     LPCTSTR pszInfPath,
  _In_     LPCTSTR pszEnvironment,
  _In_     DWORD dwFlags,
  _In_     HWND hwnd,
  _Out_    LPTSTR pszDestInfPath,
  _Inout_  PULONG pcchDestInfPath
);


I want to know what is the 5th parameter to the API?The documentation says -
hwnd [in] - A handle to the copying user interface.


which simply does not make much sense.


I have had no success to make this API work and keep getting E_INVALIDARGS return value. Since other parameters are fairly straight forward , my assumption is something is wrong about the 5th parameter.
I can make a guess that it might be the handle to the windows which is supposed to show the progress of the upload operation, though I would be happy to use the silent flag. Nonetheless, I tried using NULL as well as a dialog handle (created using CreateDialog) into this API, both in vain.

Any help will be deeply appreciated.
Posted
Updated 2-May-17 1:20am
Comments
cariolihome 29-Nov-14 10:40am    
Yes, You are right. Its a parent window for any window which will be shown by the system during upload
So, please specify other parameters. Its can help to solve E_INVALIDARGS return value.
kaushik_code 29-Nov-14 11:03am    
Not sure if I understood you correctly. Here are the other arguments
pszServer = NULL
pszInfpath = local path to the driver inf file. (eg.c:\abcd.inf)
pszEnvironment = Windows NT x86 (as mentioned in the documentation, i am using a 32 bit system)
dwFlags - UPDP_UPLOAD_ALWAYS
hwnd - ?
pszDestInfPath - pointer to wchar array of 100 chars.
pcchDestInfPath - 100

Can you help me know what should be the 5th parameter or is there a problem with any other?
cariolihome 29-Nov-14 11:07am    
5-th parameter can be NULL or a handle of any existing window
The reason of E_INVALIDARGS error is a bad value of other parameter
So, please specify exact values of all parameters.
(try set pszEnvironment to NULL since inf file has information about supported target system)
kaushik_code 29-Nov-14 11:25am    
Thank you for your response . I think the first 5 parameters are clear by my earlier comment. Regarding 6th and 7th parameter , here is what I did:

WCHAR pszDestInfPath[100] = {0};
ULONG cchDestInfPath = sizeof(pszDestInfPath)/sizeof(WCHAR);

UploadPrinterDriverPackage (
NULL,
L"C:\abcd.inf",
L"Windows NT x86",
UPDP_UPLOAD_ALWAYS,
hwndDlg, /*valid handle created by an earlier call to CreateDialog*/
pszDestInfPath,
&cchDestInfPath
);

cariolihome 29-Nov-14 11:34am    
Try this one:

WCHAR szDestInfPath[MAX_PATH];
ULONG cchDestInfPath = MAX_PATH;

UploadPrinterDriverPackage(
NULL,
L"C:\AnyFolder\InfFile.inf",
NULL,
0,
NULL,
szDestInfPath,
&cchDestInfPath);

Does inf file have CatalogFile directive ?
Does *.cat file specified in CatalogFile directive exist on file system ?

if you use the flag UPDP_SILENT_UPLOAD a NULL hwnd should be working. See UploadPrinterDriverPackage documentation.
 
Share this answer
 
Thanks to cariolihome for this comment

According to the UploadPrinterDriverPackage function implementation cchDestInfPath cant be less then MAX_PATH character
 
Share this answer
 
Comments
BillWoodruff 15-Dec-14 9:33am    
Please post replies and comments to a person who left a comment to you, or answered your question, by using the "Have a Question or Comment?" button. Do not post replies/comments as "solutions" as you do here.
kaushik_code 15-Dec-14 22:45pm    
But the comment led to a solution here. That is why it has been pasted as a solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900