Need help with SPOOLSS.DLL

This forum is for general support of Xbase++
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Need help with SPOOLSS.DLL

#1 Post by rdonnay »

I have been working on a routine that loads custom printer forms into a printer.

This uses the BAP package for creating structures and the Windows API function: AddForm().

AddForm() exists in SPOOLSS.DLL.

My program fails because SPOOLSS.DLL will not load.

I ran ESET anti-virus scan against the SPOOLSS.DLL and set all the proper permissions.
Still no go.

I need to have other eXpress++ users do something for me and tell me the results.

1. Start up XDOT.EXE
2. At the prompt type: n := DllLoad('SPOOLSS.DLL')
3. At the prompt type: ? n

Please tell me what value is returned. If it is a 0 then you also cannot load SPOOLSS.DLL.
If it is a positive number then you don't have the problem.
Also, please tell me the date, time and size of your c:\windows\system32\spoolss.dll.

Thank you.
The eXpress train is coming - and it has more cars.

Koverhage
Posts: 151
Joined: Mon Feb 01, 2010 8:45 am

Re: Need help with SPOOLSS.DLL

#2 Post by Koverhage »

Roger,

here i can't load spoolss.dll (Date 2009/07/14, Time 03:31, 57856 Bytes, Win 7)
Klaus

Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Need help with SPOOLSS.DLL

#3 Post by Wolfgang Ciriack »

Same here - spoolss.dll (Date 2015/07/15, Time 05:18, 92672 Bytes, Win 10)
_______________________
Best Regards
Wolfgang

User avatar
Auge_Ohr
Posts: 1406
Joined: Wed Feb 24, 2010 3:44 pm

Re: Need help with SPOOLSS.DLL

#4 Post by Auge_Ohr »

rdonnay wrote:I have been working on a routine that loads custom printer forms into a printer.

This uses the BAP package for creating structures and the Windows API function: AddForm().

AddForm() exists in SPOOLSS.DLL.
have not try "AddForm" yet but all my other Printer*** API Function point to winspool.drv
***https://msdn.microsoft.com/de-de/librar ... s.85).aspx

https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Image

also look at this http://www.codeproject.com/Articles/891 ... chitecture
VS DotNet Code http://www.codeproject.com/Articles/122 ... d-printers

found VB Code on MSDN
https://support.microsoft.com/en-us/kb/282474

Code: Select all

Public Declare Function AddForm Lib "winspool.drv" Alias "AddFormA" _
    (ByVal hPrinter As Long, ByVal Level As Long, pForm As Byte) As Long

Public Declare Function DeleteForm Lib "winspool.drv" Alias "DeleteFormA" _
    (ByVal hPrinter As Long, ByVal pFormName As String) As Long    
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need help with SPOOLSS.DLL

#5 Post by rdonnay »

Code: Select all

Public Declare Function AddForm Lib "winspool.drv" Alias "AddFormA" _
    (ByVal hPrinter As Long, ByVal Level As Long, pForm As Byte) As Long
If this is correct then the Microsoft online documentation is incorrect.
I had already tried AddFormA but not winspool.drv.

I DID use winspool.drv for OpenPrinter().

Ok, after using winspool.drv and AddFormA I finally get the dll to load.
I had IDSC problems until I got all the pointers correct in the 2 structures.

Now it runs without a runtime error but always returns 0, meaning there was a failure.
One of the frustrations of the Window API is that it doesn't give any explanation of the failure.
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Need help with SPOOLSS.DLL

#6 Post by rdonnay »

I finally have been able to run my routine without an error.

It adds the form with the correct name but not with the correct sizes.

The spec says the width and height should be in thousands of millimeters.

No matter what numbers I use, from 0 to 200000, the width and height in the added form shows as 11099.62in.

Any ideas on what's going on?

I have not found any BAP sample programs that show how to use a BAP structure within another BAP structure.
I may be doing this wrong but I don't know any other method.

Here is my code:

Code: Select all

/*
BOOL AddForm(
  _In_ HANDLE hPrinter,
  _In_ DWORD  Level,
  _In_ LPBYTE pForm
);

The FORM_INFO_1 structure contains information about a print form.
The information includes the print form's origin, its name,
its dimensions, and the dimensions of its printable area.

Syntax

C++

typedef struct _FORM_INFO_1 {
  DWORD  Flags;
  LPTSTR pName;
  SIZEL  Size;
  RECTL  ImageableArea;
} FORM_INFO_1, *PFORM_INFO_1;

Members

Flags

The form properties. The following values are defined.

Value          Meaning

FORM_USER      If this bit flag is set, the form has been defined by the user.
               Forms with this flag set are defined in the registry.

FORM_BUILTIN   If this bit-flag is set, the form is part of the spooler.
               Form definitions with this flag set do not appear in the registry.

FORM_PRINTER   If this bit flag is set, the form is associated with a certain
               printer, and its definition appears in the registry.

pName

Pointer to a null-terminated string that specifies the name of the form.
The form name cannot exceed 31 characters.

Size

The width and height, in thousandths of millimeters, of the form.

ImageableArea

The width and height, in thousandths of millimeters, of the form.

Requirements


Printing
Print Spooler API Structures
AddForm
GetForm
SetForm
*/

#INCLUDE "dcdialog.CH"
#INCLUDE "dll.CH"
#INCLUDE "bap.CH"

#define FORM_USER    0
#define FORM_BUILTIN 1
#define FORM_PRINTER 2

STATIC snHdll

FUNCTION Main()

LOCAL cPrinterName := 'Epson ESC/P-R', ;
      cFormName := 'RogerTestForm'

x := PrinterAddForm( cPrinterName, cFormName, 200, 250 )

? x
wait

RETURN nil

* -----------

FUNCTION SizeStructure( nWidth, nHeight )

LOCAL aBin := BaInit(2), cBin

BaStruct( aBin, nWidth )   // Width
BaStruct( aBin, nHeight )  // height

cBin := BaAccess(aBin)

RETURN cBin

* -----------

FUNCTION FormStructure( nFlags, cFormName, sSize, sRect )

LOCAL aBin := BaInit(4), cBin

cFormName := Pad(cFormName+Chr(0),31)
BaStruct( aBin, nFlags )  // Flags
BaStruct( aBin, @cFormName )  // Name
BaStruct( aBin, @sSize )  // SIZEL
BaStruct( aBin, @sRect )  // RECTL

cBin := BaAccess(aBin)

RETURN cBin

* -------------

FUNCTION PrinterAddForm( cPrinterName, cFormName, nWidth, nHeight )

LOCAL sSize, sRect, nFlags, hPrinter := 0, sForm, nLevel := 1

sSize := SizeStructure( nWidth, nHeight )
sRect := SizeStructure( nWidth, nHeight )

nFlags := FORM_USER + FORM_PRINTER

sForm := FormStructure( nFlags, cFormName, @sSize, @sRect )

x := OpenPrinterA( cPrinterName, @hPrinter, nil )

wtf x, hPrinter

IF hPrinter > 0
  RETURN AddFormA( hPrinter, nLevel, sForm )
ENDIF

RETURN -1

* -------------

DLLFUNCTION AddFormA( hPrinter, nLevel, @sForm ) USING STDCALL FROM WINSPOOL.DRV

DLLFUNCTION OpenPrinterA( cPrinterName, @hPrinter, sDefaults ) USING STDCALL FROM WINSPOOL.DRV
The eXpress train is coming - and it has more cars.

Post Reply