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