Changeset 44977 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Mar 11, 2013 11:36:51 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/win/VBoxGuestInst.cpp
r44528 r44977 1 /* $Id$ */ 1 2 /** @file 2 * 3 * Small tool to (un)install the VBoxGuest device driver 4 * 3 * Small tool to (un)install the VBoxGuest device driver. 4 */ 5 6 /* 5 7 * Copyright (C) 2006-2010 Oracle Corporation 6 8 * … … 31 33 32 34 33 int installDriver(void)35 static int installDriver(void) 34 36 { 35 37 /* … … 58 60 NULL, NULL, NULL, NULL); 59 61 if (!hService) 60 {61 62 printf("CreateService failed! lasterr=%d\n", GetLastError()); 62 } else 63 { 63 else 64 64 CloseServiceHandle(hService); 65 }66 65 CloseServiceHandle(hSMgrCreate); 67 66 return hService ? 0 : -1; 68 67 } 69 68 70 int uninstallDriver(void)69 static int uninstallDriver(void) 71 70 { 72 71 int rc = -1; … … 97 96 } 98 97 98 #ifdef TESTMODE 99 99 100 HANDLE openDriver(void)100 static HANDLE openDriver(void) 101 101 { 102 102 HANDLE hDevice; … … 116 116 } 117 117 118 int closeDriver(HANDLE hDevice)118 static int closeDriver(HANDLE hDevice) 119 119 { 120 120 CloseHandle(hDevice); … … 122 122 } 123 123 124 #ifdef TESTMODE 125 typedef struct TESTFOO 126 { 127 int values[16]; 128 } TESTFOO, *PTESTFOO; 129 130 int performTest(void) 124 static int performTest(void) 131 125 { 132 126 int rc = 0; … … 135 129 136 130 if (hDevice != INVALID_HANDLE_VALUE) 137 {138 DWORD cbReturned;139 140 131 closeDriver(hDevice); 141 } else 142 { 132 else 143 133 printf("openDriver failed!\n"); 144 }145 146 134 147 135 return rc; 148 136 } 149 #endif150 137 151 void displayHelpAndExit(char *programName) 138 #endif /* TESTMODE */ 139 140 static int usage(char *programName) 152 141 { 153 142 printf("error, syntax: %s [install|uninstall]\n", programName); 154 exit(1);143 return 1; 155 144 } 156 145 … … 163 152 164 153 if (argc != 2) 165 { 166 displayHelpAndExit(argv[0]); 167 } 154 return usage(argv[0]); 155 168 156 if (strcmp(argv[1], "install") == 0) 169 {170 157 installMode = true; 171 } else 172 if (strcmp(argv[1], "uninstall") == 0) 173 { 158 else if (strcmp(argv[1], "uninstall") == 0) 174 159 installMode = false; 175 } else176 160 #ifdef TESTMODE 177 if (strcmp(argv[1], "test") == 0) 178 { 161 else if (strcmp(argv[1], "test") == 0) 179 162 testMode = true; 180 } else181 163 #endif 182 {183 displayHelpAndExit(argv[0]);184 } 164 else 165 return usage(argv[0]); 166 185 167 186 168 int rc; 187 188 169 #ifdef TESTMODE 189 170 if (testMode) 190 {191 171 rc = performTest(); 192 }else172 else 193 173 #endif 194 174 if (installMode) 195 {196 175 rc = installDriver(); 197 } else 198 { 176 else 199 177 rc = uninstallDriver(); 200 }201 178 202 179 if (rc == 0) 203 {204 180 printf("operation completed successfully!\n"); 205 } else 206 { 181 else 207 182 printf("error: operation failed with status code %d\n", rc); 208 }209 183 210 184 return rc; 211 185 } 186
Note:
See TracChangeset
for help on using the changeset viewer.