This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: DeletePrinterDriver MSDN Function
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 23, 2015
05:12 AM
DeletePrinterDriver MSDN Function
Hi,
I wonder if someone could help, I'm having trouble porting an msdn function into my installscript; Im attempting to use the DeletePrinterDriver function;
https://msdn.microsoft.com/en-us/library/windows/desktop/dd183545(v=vs.85).aspx
When I run it I get a setup interrupted and the function never completes and moves on to the next call so I know there must be something fundamentally wrong here.
My typedef looks like;
And my code looks like this;
It compiles ok however every-time I run it I get the following error;
CustomAction del_swi_DeletePrinterDriver returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 11:01:23: del_swi_DeletePrinterDriver. Return value 3.
This isn't very helpful.
I'm already successfully using the SetupUninstallOEMInfA, SetupCopyOEMInfA functions in the same manner but can't work out why this isn't working and the error messages aren't v.helpful, anyone have any suggestions???
Thanks in advance
I wonder if someone could help, I'm having trouble porting an msdn function into my installscript; Im attempting to use the DeletePrinterDriver function;
https://msdn.microsoft.com/en-us/library/windows/desktop/dd183545(v=vs.85).aspx
When I run it I get a setup interrupted and the function never completes and moves on to the next call so I know there must be something fundamentally wrong here.
My typedef looks like;
prototype BOOL SETUPAPI.DeletePrinterDriver(
POINTER, //_In_ LPTSTR pName,
POINTER,//_In_ LPTSTR pEnvironment,
BYREF STRING //_In_ LPTSTR pDriverName
);
And my code looks like this;
function del_swi_DeletePrinterDriver(hMSI)
STRING szDriverName;
begin
szDriverName = "Canon iR C2880/C3380";
if( DeletePrinterDriver(NULL,NULL,szDriverName) = 0 ) then
MessageBox(FormatMessage(Err.LastDllError), WARNING);
Err = GetLastError();
SprintfBox( INFORMATION, "CustomAction: RegisterDriverINF", "SetupCopyOEMInfA Failed: %s",Err);
endif;
MessageBox("Function Delete Driver - Complete", WARNING);
end;
It compiles ok however every-time I run it I get the following error;
CustomAction del_swi_DeletePrinterDriver returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
Action ended 11:01:23: del_swi_DeletePrinterDriver. Return value 3.
This isn't very helpful.
I'm already successfully using the SetupUninstallOEMInfA, SetupCopyOEMInfA functions in the same manner but can't work out why this isn't working and the error messages aren't v.helpful, anyone have any suggestions???
Thanks in advance
- Tags:
- msdn function call.
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 23, 2015
08:08 AM
Since InstallShield 2011 or so, we will default to using Unicode entry points when available. Because of this, you should either specify DeletePrinterDriverA, or use WSTRING and/or WPOINTER types to correspond to LPTSTR / LPCTSTR (or of course LPWSTR / LPCWSTR) parameters. I would start with that, and if that doesn't help, also consider seeing if you can get further information with a try/catch block.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 24, 2015
06:12 AM
You can try to write a little VBA (i.e. office or something else you have) and test the WIN API function.
Declare Function DeletePrinterDriver Lib "winspool.drv" Alias "DeletePrinterDriverA" (ByVal pName As String, ByVal pEnvironment As String, ByVal pDriverName As String) As Long
There you can check if it in principle work for your case.
regards
Markus
Declare Function DeletePrinterDriver Lib "winspool.drv" Alias "DeletePrinterDriverA" (ByVal pName As String, ByVal pEnvironment As String, ByVal pDriverName As String) As Long
There you can check if it in principle work for your case.
regards
Markus
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 26, 2015
03:20 AM
MichaelU wrote:
Since InstallShield 2011 or so, we will default to using Unicode entry points when available. Because of this, you should either specify DeletePrinterDriverA, or use WSTRING and/or WPOINTER types to correspond to LPTSTR / LPCTSTR (or of course LPWSTR / LPCWSTR) parameters. I would start with that, and if that doesn't help, also consider seeing if you can get further information with a try/catch block.
How would I execute a try and catch block as none of the suggestions you've offered here seem to work?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 26, 2015
08:25 AM
See the help topic Exception Handling, and on the Err Object. When you catch an exception, you can examine the properties on the Err object for possible additional information.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 26, 2015
08:36 AM
MichaelU wrote:
See the help topic Exception Handling, and on the Err Object. When you catch an exception, you can examine the properties on the Err object for possible additional information.
Thanks for that it's not too helpful though, no matter what I change I get the same error, I also get the same with OpenPrinter Call as well;
c
prototype BOOL SETUPAPI.DeletePrinterDriverW(c
WPOINTER, //_In_ LPTSTR pName,
WPOINTER,//_In_ LPTSTR pEnvironment,
WSTRING //_In_ LPTSTR pDriverName
);
prototype BOOL SETUPAPI.OpenPrinterW(
WSTRING, //_In_ LPTSTR pPrinterName,
NUMBER,//_Out_ LPHANDLE phPrinter,
WPOINTER//_In_ LPPRINTER_DEFAULTS pDefault
);
try
OpenPrinterW(szDriverName, Printer, NULL);
catch
Err = GetLastError();
SprintfBox (INFORMATION, "L862Error","Error occured: %i\n\n%s\n\n%s", Err.Number, Err.Description, Err.LastDllError);
endcatch;
MessageBox("Open Printer - Complete", WARNING);
MessageBox("DeletePrinterDriverW - Starting", WARNING);
try
if( DeletePrinterDriverW(NULL,NULL,szDriverName) = 0 ) then
MessageBox(FormatMessage(Err.LastDllError), WARNING);
Err = GetLastError();
SprintfBox( INFORMATION, "CustomAction: RegisterDriverINF", "DeletePrinterDriverA Failed: %s",Err);
endif;
catch
SprintfBox (INFORMATION, "Error","Error occured: %i\n\n%s\n\n%s", Err.Number, Err.Description, Err.LastDllError);
endcatch;
I always get a -2147219709 error so unable to run any of these functions, its especially weird as I can run the following two API's ok
prototype BOOL SETUPAPI.SetupCopyOEMInfA( // ASCII Version From SetupAPI.h
POINTER, //IN PCSTR SourceInfFileName,
POINTER, //IN PCSTR OEMSourceMediaLocation, OPTIONAL
POINTER, //IN DWORD OEMSourceMediaType,
POINTER, //IN DWORD CopyStyle,
BYREF STRING, //OUT PSTR DestinationInfFileName, OPTIONAL
POINTER, //IN DWORD DestinationInfFileNameSize, Set MAX_PATH
POINTER, //OUT PDWORD RequiredSize, OPTIONAL
POINTER //OUT PSTR *DestinationInfFileNameComponent OPTIONAL
);
//MSDN api to remove infe file from Magu to /inf and file repo
prototype BOOL SETUPAPI.SetupUninstallOEMInfA(
POINTER, // PCWSTR InfFileName,
NUMBER, // _In_ DWORD Flags,
POINTER //_In_ PVOID Reserved
);
And yes I've tried OpenPrinterA and DeletePrinterDriverA in teh same format as the OEMSetups, same error.
V.Strange!!
Any Idea's?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 26, 2015
10:14 AM
MarkusLatz wrote:
You can try to write a little VBA (i.e. office or something else you have) and test the WIN API function.
Declare Function DeletePrinterDriver Lib "winspool.drv" Alias "DeletePrinterDriverA" (ByVal pName As String, ByVal pEnvironment As String, ByVal pDriverName As String) As Long
There you can check if it in principle work for your case.
regards
Markus
Hi Markus,
I'm also having problems with OpenPrinter, could you give me some pointer is what the VBS would look like to check I get a return value for this?
![](/skins/images/D60DF682EA37BF37032955CE10F3F0BB/responsive_peak/images/icon_anonymous_message.png)