Windows API FindExecutable help!

aru_aakash

Board Regular
Joined
May 22, 2009
Messages
74
Hello Gurus,


I have following line of codes :

<code>
Code:
Function Exec(strFile As String) As String
    Dim strPath As String


    Dim ALen As Integer


    strPath = Space(255)


    ALen = FindExecutableA(strFile, "\", strPath)


    Exec = Trim(strPath)


End Function
</code>
The above UDF uses API call to FindExecutable function.

Query: Last line of code gives nothing to Exec function. But still on supplying the filename and path to this function, i am getting the executable file path.

Also i do not understand where ALen is used.

Please advise. As i am finding difficultly in understanding DLL's functions.

Thanks<code></code>
 
Last edited by a moderator:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
see also:
FindExecutable function (Windows)

ALen = FindExecutableA(strFile, "\", strPath)
you pass the function the filename and a path, and an empty string to hold the application used to open the feilname.

so the if strFile = 123.xls, then FindExecutable will put Excel.exe in strPath

The function also returns a value, which is captured in ALen. In your example ALen is not checked. But you could check it for errors: if ALen is 32 or more then the function was successful, else there are a number of errors with different values (see link). For proper coding your function should do this, else the user may come up with some surprises
 
Upvote 0

Forum statistics

Threads
1,203,524
Messages
6,055,905
Members
444,832
Latest member
bgunnett8

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top