-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsk.cpp
43 lines (27 loc) · 804 Bytes
/
dsk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <windows.h>
#include <stdio.h>
void printusage(char *program) {
fprintf(stderr, "Usage: %s background-file.bmp\n", program);
fprintf(stderr, " Changes desktop background to background-file\n");
return;
}
int main(int argc, char *argp[]) {
DWORD dResult;
BOOL result;
if (argc != 2) {
printusage(argp[0]);
return 1;
}
result = SystemParametersInfo(
SPI_SETDESKWALLPAPER,
0,
argp[1],
0);
if (!result) {
dResult = GetLastError();
fprintf(stderr, "Attempt to set new desktop background failed.\nError code: %d\n\n", dResult);
return 2;
}
fprintf(stderr, "Desktop background changed to: %s\n\n", argp[1]);
return 0;
}