Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Reference
Shell Functions
 FindExecutable Function

  Switch on low bandwidth view
FindExecutable Function

Retrieves the name of and handle to the executable (.exe) file associated with a specific document file.

Syntax

HINSTANCE FindExecutable(      
    LPCTSTR lpFile,     LPCTSTR lpDirectory,     LPTSTR lpResult );

Parameters

lpFile
[in] The address of a null-terminated string that specifies a file name. This file should be a document.
lpDirectory
[in] The address of a null-terminated string that specifies the default directory. This value can be NULL.
lpResult
[out] The address of a buffer that receives the file name of the associated executable file. This file name is a null-terminated string that specifies the executable file started when an "open" by association is run on the file specified in the lpFile parameter. Put simply, this is the application that is launched when the document file is directly double-clicked or when Open is chosen from the file's shortcut menu. This parameter must contain a valid non-null value and is assumed to be of length MAX_PATH. Responsibility for validating the value is left to the programmer.

Return Value

Returns a value greater than 32 if successful, or a value less than or equal to 32 representing an error.

The following table lists possible error values.

SE_ERR_FNFThe specified file was not found.
SE_ERR_NOASSOCThere is no association for the specified file type.
SE_ERR_OOMMicrosoft Windows XP only. The system is out of memory or resources.

Remarks

Use FindExecutable for documents. If you want to retrieve the path of an executable file, use the following:

AssocQueryString(ASSOCF_OPEN_BYEXENAME,
                 ASSOCSTR_EXECUTABLE,
                 pszExecutableName,
                 NULL,
                 pszPath,
                 pcchOut);

Here, pszExecutableName is a pointer to a null-terminated string that specifies the name of the executable file, pszPath is a pointer to the null-terminated string buffer that receives the path to the executable file, and pcchOut is a pointer to a DWORD that specifies the number of characters in the pszPath buffer. When the function returns, pcchOut is set to the number of characters actually placed in the buffer. See AssocQueryString for more information.

When FindExecutable returns, the lpResult parameter may contain the path to the Dynamic Data Exchange (DDE) server started if a server does not respond to a request to initiate a DDE conversation with the DDE client application.

Function Information

Minimum DLL Versionshell32.dll
Custom ImplementationNo
Headershellapi.h
Import libraryshell32.lib
Minimum operating systems Windows NT 3.1, Windows 95
UnicodeImplemented as ANSI and Unicode versions.

See Also

ShellExecute
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
List of constants returned by FindExecutable      bgaucke   |   Edit   |   Show History
//from SHELLAPI.H

#define SE_ERR_FNF 2 // file not found
#define SE_ERR_OOM 8 // out of memory
#define SE_ERR_NOASSOC 31//association not found(either in registry or found filename in reg but not in filesystem)
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker