annotate libdha/dhahelperwin/dhasetup.c @ 22164:ef142bfc30fb

Handle libavformat libnut dependencies. Fixes compilation after ffmpeg r7891.
author uau
date Fri, 09 Feb 2007 19:44:43 +0000
parents 33dab236c631
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
1 /* dhahelper setup program (c) 2004 Sascha Sommer */
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
2 /* compile with gcc -o dhasetup.exe dhasetup.c */
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
3 /* LICENSE: GPL */
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
4
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
5 #include <windows.h>
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
6 #include <stdio.h>
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
7
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
8 int main(int argc,char* argv[]){
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
9 SC_HANDLE hSCManager;
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
10 SC_HANDLE hService;
12058
faust3
parents: 12057
diff changeset
11 char path[MAX_PATH];
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
12 printf("dhasetup (c) 2004 Sascha Sommer\n");
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
13 GetWindowsDirectory(path,MAX_PATH);
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
14 strcpy(path+strlen(path),"\\system32\\drivers\\dhahelper.sys");
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
15 if(argc==1){
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
16 printf("Usage:\n");
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
17 printf("dhasetup install - Copies dhahelper.sys from the current directory to\n%s and configures it to start at boot.\n", path);
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
18 printf("dhasetup remove - Removes the dhahelper utility.\n");
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
19 return 0;
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
20 }
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
21 hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
22 if(!strcmp(argv[1],"install")){
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
23 printf("Installing dhahelper...\n");
12453
faust3
parents: 12452
diff changeset
24 if(!CopyFile("dhahelper.sys",path,FALSE)){
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
25 printf("Copying dhahelper.sys failed.\nEither dhahelper.sys is not in the current directory or you lack sufficient\nprivileges to write to %s.", path);
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
26 return 1;
12453
faust3
parents: 12452
diff changeset
27 }
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
28 // Install the driver
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
29 hService = CreateService(hSCManager,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
30 "DHAHELPER",
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
31 "DHAHELPER",
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
32 SERVICE_ALL_ACCESS,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
33 SERVICE_KERNEL_DRIVER,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
34 SERVICE_SYSTEM_START,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
35 SERVICE_ERROR_NORMAL,
12058
faust3
parents: 12057
diff changeset
36 path,
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
37 NULL,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
38 NULL,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
39 NULL,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
40 NULL,
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
41 NULL);
12450
238820c0ee48 report if the service creation failed
faust3
parents: 12098
diff changeset
42 if(!hService){
12452
diego
parents: 12450
diff changeset
43 printf("Unable to register DHAHELPER Service (0x%x).\n",GetLastError());
12450
238820c0ee48 report if the service creation failed
faust3
parents: 12098
diff changeset
44 }
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
45 }
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
46 else if(!strcmp(argv[1],"remove")){
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
47 SERVICE_STATUS ServiceStatus;
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
48 printf("Removing dhahelper...\n");
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
49 hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS);
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
50 ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus);
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
51 DeleteService(hService);
12058
faust3
parents: 12057
diff changeset
52 DeleteFile(path);
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
53 }
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
54 else {
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
55 printf("unknown parameter: %s\n",argv[1]);
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
56 }
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
57 CloseServiceHandle(hService);
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
58 CloseServiceHandle(hSCManager);
12098
73ee9bd3b537 Error message improved, wording.
diego
parents: 12058
diff changeset
59 printf("Please reboot to let the changes take effect.\n");
12057
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
60 return 0;
0f058e9cd422 Windows XP support
faust3
parents:
diff changeset
61 }