- dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, sizeof(szExePath) / sizeof(szExePath[0]), szExePath, NULL);
- if ((dwSearchReturn == 0) || (dwSearchReturn > sizeof(szExePath) / sizeof(szExePath[0])))
+#ifdef __REACTOS__
+ if (RetPtr)
+ *RetPtr = NULL;
+
+ if (ExpandEnvironmentStringsW(lpszExeFileName, szExpandedExePath, ARRAY_SIZE(szExpandedExePath)))
+ lpszExeFileName = szExpandedExePath;
+#endif
+
+ dwSearchReturn = SearchPathW(NULL, lpszExeFileName, NULL, ARRAY_SIZE(szExePath), szExePath, NULL);
+ if ((dwSearchReturn == 0) || (dwSearchReturn > ARRAY_SIZE(szExePath)))