else {
if (! SetEnvironmentVariable(s, NULL)) ret++;
}
- for (t++ ; *t; t++);
+ for (t++; *t; t++);
}
s = t;
}
-1 on error.
*/
int test_environment(TCHAR *env) {
- TCHAR path[PATH_LENGTH];
- GetModuleFileName(0, path, _countof(path));
+ TCHAR *path = (TCHAR *) nssm_imagepath();
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
duplicate_environment(newenv);
HeapFree(GetProcessHeap(), 0, newenv);
}
+
+/* Safely get a copy of the current environment. */
+TCHAR *copy_environment() {
+ TCHAR *rawenv = GetEnvironmentStrings();
+ if (! rawenv) return NULL;
+ TCHAR *env = copy_environment_block(rawenv);
+ FreeEnvironmentStrings(rawenv);
+ return env;
+}