001
13.12.2002, 17:41 Uhr
virtual
Sexiest Bit alive (Operator)
|
Hat sich erledigt:
C++: |
#include "stdafx.h" #include <windows.h> #include <stdlib.h>
int main(int argc, char* argv[]) { const char* szPrgName = argv[0] + strlen(argv[0]); HKEY hEnvironment;
/* * Check command line */ while(szPrgName!=argv[0] && szPrgName[-1]!='/' && szPrgName[-1]!='\\') --szPrgName;
if (argc!=3) { fprintf(stderr, "*** ERROR %s: illegal command line:\n" "usage: %s key value\n", szPrgName, szPrgName); exit(EXIT_FAILURE); }
/* * Get registry key to environment */ if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CURRENT_USER, "Environment", NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hEnvironment, NULL)) { fprintf(stderr, "*** ERROR %s: RegCreateKeyEx failed!\n", szPrgName); exit(EXIT_FAILURE); }
/* * Write setting to registry */ if (ERROR_SUCCESS != RegSetValueEx(hEnvironment, argv[1], 0, REG_SZ, (const unsigned char*)argv[2], strlen(argv[2])+1)) { fprintf(stderr, "*** ERROR %s: RegSetValueEx failed!\n", szPrgName); exit(EXIT_FAILURE); }
/* * Close the key */ if (ERROR_SUCCESS != RegCloseKey(hEnvironment)) { fprintf(stderr, "*** ERROR %s: RegCloseKey failed!\n", szPrgName); exit(EXIT_FAILURE); }
return EXIT_SUCCESS; }
|
-- Gruß, virtual Quote of the Month Ich eß' nur was ein Gesicht hat (Creme 21) |