PRB: FindExecutable() Truncates Result at First Space in LFNID: Q140724
|
The FindExecutable function is supposed to retrieve the fully qualified
path to the executable (.exe) file associated with the specified file name.
For example, the following call to FindExecutable() should return the path
to Winword.exe:
FindExecutable ("C:\\README.DOC", NULL, szBuffer);
C:\Program Files\My Accessories\Winword.Exe
File associations are stored in the registry under HKEY_CLASS_ROOT, where
the executable name is actually stored under the key
HKEY_CLASSES_ROOT\<file Type>\shell\open\command = <Name of Executable>
HKEY_CLASSES_ROOT\Word.Document.6\shell\open\command =
"C:\Program Files\My Accessories\Winword.Exe" /n
In some situations, applications do not have control over what gets stored
in the registry. It may be the associated application's setup program that
wrote the incorrect LFN string (without quotation marks) to the registry.
Any application that would then call FindExecutable() on this associated
application will run into this problem.
One workaround to this problem might be to parse the string returned and
replace the \0 character with a space. Stepping through a debugger, after
FindExecutable() returns, you will quickly find that although the space has
been replaced with the NULL character (\0), the rest of the string is left
intact, so simply reverting the \0 character back to a space gives the
expected string.
This behavior is by design.
Additional query words: invalid wrong
Keywords : kbLib kbNTOS kbWinOS95 kbWinOS98 kbGrpShell
Version :
Platform :
Issue type : kbprb
Last Reviewed: March 6, 1999