#include <shellapi.h> |
HINSTANCE FindExecutable(lpszFile, lpszDir, lpszResult) | |||||
LPCSTR lpszFile; | /* address of string for filename | */ | |||
LPCSTR lpszDir; | /* address of string for default directory | */ | |||
LPSTR lpszResult; | /* address of string for executable file on return | */ |
The FindExecutable function finds and retrieves the executable filename that is associated with a specified filename.
lpszFile
Points to a null-terminated string specifying a filename. This can be a document or executable file.
lpszDir
Points to a null-terminated string specifying the drive letter and path for the default directory.
lpszResult
Points to a buffer that receives the name of an executable file when the function returns. This null-terminated string specifies the application that is started when the Open command is chosen from the File menu in File Manager.
The return value is greater than 32 if the function is successful. If the return value is less than or equal to 32, it specifies an error code.
The FindExecutable function returns 31 if there is no association for the specified file type. The other possible error values are as follows:
Value | Meaning |
0 | System was out of memory, executable file was corrupt, or relocations were invalid. |
2 | File was not found. |
3 | Path was not found. |
5 | Attempt was made to dynamically link to a task, or there was a sharing or network-protection error. |
6 | Library required separate data segments for each task. |
8 | There was insufficient memory to start the application. |
10 | Windows version was incorrect. |
11 | Executable file was invalid. Either it was not a Windows application or there was an error in the .EXE image. |
12 | Application was designed for a different operating system. |
13 | Application was designed for MS-DOS 4.0. |
14 | Type of executable file was unknown. |
15 | Attempt was made to load a real-mode application (developed for an earlier version of Windows). |
16 | Attempt was made to load a second instance of an executable file containing multiple data segments that were not marked read-only. |
19 | Attempt was made to load a compressed executable file. The file must be decompressed before it can be loaded. |
20 | Dynamic-link library (DLL) file was invalid. One of the DLLs required to run this application was corrupt. |
21 | Application requires Microsoft Windows 32-bit extensions. |
The filename specified in the lpszFile parameter is associated with an executable file when an association has been registered between that file's filename extension and an executable file in the registration database. An application that produces files with a given filename extension typically associates the extension with an executable file when the application is installed.