A:可以自己写 custom action #include <stdio.h> #include <windows.h> #include <winreg.h> int main() { HKEY hKey; char keyname[100]="SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment"; long lResult; DWORD dwType; char sz_compupath[80]; char sz_compudrive[80]; DWORD dwDataSize=80; memset(sz_compupath,0,80); memset(sz_compudrive,0,80); lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_ALL_ACCESS , &hKey); lResult = RegQueryValueEx(hKey,"compudrive", NULL, &dwType, (BYTE*)sz_compudrive, &dwDataSize); dwDataSize=80; lResult = RegQueryValueEx(hKey,"compupath", NULL, &dwType, (BYTE*)sz_compupath, &dwDataSize); if( lResult == ERROR_SUCCESS ) { //printf("compupath = %s\n", sz_compupath); sz_compudrive[0] = sz_compupath[0]; sz_compudrive[1] = sz_compupath[1]; sz_compudrive[2] = NULL; wsprintf(sz_compupath, "%s", &sz_compupath[2]); dwDataSize = dwDataSize - 2; if ( sz_compupath[strlen(sz_compupath)-1] == '\\' ) { sz_compupath[strlen(sz_compupath)-1] = NULL; dwDataSize = dwDataSize - 1; } lResult = RegSetValueEx(hKey, "compupath", NULL, dwType, sz_compupath, dwDataSize); dwDataSize = 3; lResult = RegSetValueEx(hKey, "compudrive", NULL, dwType, sz_compudrive, dwDataSize); lResult = RegFlushKey(hKey); } //printf("\nAfter:\n"); dwDataSize=80; lResult = RegQueryValueEx(hKey,"compudrive", NULL, &dwType, (BYTE*)sz_compudrive, &dwDataSize); /* if( lResult == ERROR_SUCCESS ) { printf("compudrive = %s\n", sz_compudrive); } */ dwDataSize=80; lResult = RegQueryValueEx(hKey,"compupath", NULL, &dwType, (BYTE*)sz_compupath, &dwDataSize); /* if( lResult == ERROR_SUCCESS ) { printf("compupath = %s\n", sz_compupath); } */
RegCloseKey(hKey); DWORD dwReturnValue; SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM) "Environment", SMTO_ABORTIFHUNG, 5000, &dwReturnValue); return 0; }<-- / message -->
|