add SetPrinterDataExW.exe.
[gd/win32-spoolss/.git] / DeleteForm.c
1 /******************************************************************
2  * SPOOLSS regression testing code for Samba print servers
3  *
4  *****************************************************************/
5
6 #include <windows.h>
7 #include <stdio.h>
8 #include "printlib.h"
9
10
11 int main (int argc, char* argv[])
12 {
13
14         HANDLE                  printer;
15         LPVOID                  lpMsgBuf;
16
17         if (argc < 2)
18         {
19                 fprintf (stderr, "useage: %s <printername> <form name>\n", argv[0]);
20                 exit (-1);
21         }
22
23         /* open the printer */
24         if (!OpenPrinter (argv[1], &printer, NULL))
25         {
26                 fprintf (stderr, "Unable to open %s!\n", argv[1]);
27                 exit (-1);
28         }
29         else
30         {
31                 printf ("Printer [%s] opened successfully.\n\n", argv[1]);
32         }
33
34         printf ("Attempting to remove %s...\n", argv[2]);
35         if (!DeleteForm(printer, (LPTSTR)argv[2]))
36         {
37                 FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
38                         FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(),
39                         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
40                         (LPTSTR) &lpMsgBuf, 0, NULL);
41                 printf ("ERROR : %s\n", (char*)lpMsgBuf);
42                 LocalFree (lpMsgBuf);
43         }
44         else
45         {
46                 printf ("Form removed successfully!\n");
47         }
48         printf ("\n");
49
50
51         /* close the printer */
52         if (!ClosePrinter(printer))
53         {
54                 fprintf (stderr, "Error closing printer!\n");
55                 exit (-1);
56         }
57         else
58         {
59                 printf ("Printer [%s] closed successfully.\n", argv[1]);
60         }
61
62         return 0;
63
64 }