static const char *EVFILE[] = {"System", "Security", "Application"}; ... /* Which EventLog are we reading? */ for (j=0; j < (sizeof(EVFILE)/sizeof(EVFILE[0])); j++) { sprintf(regPath, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s", EVFILE[j], source); if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, regPath, 0, KEY_READ, &hk) == ERROR_SUCCESS) { break; } }