From: Tony Toews [MVP] on
Folks

The API call "FindExecutable: Find Exe Associated with a Registered
Extension"
http://vbnet.mvps.org/index.html?code/system/findexecutable.htm fails
on a file with the ACCDB extension. The API call does work fine with
the MDB extension. Clicking on an ACCDB file in Windows Explorer
does work.

This is a on a new, fresh Win XP/Access 2007 install with nothing else
on the system and no uninstalls, etc.

This behavior puzzles me greatly.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
From: mayayana on
>
> The API call "FindExecutable: Find Exe Associated with a Registered
> Extension"
> http://vbnet.mvps.org/index.html?code/system/findexecutable.htm fails
> on a file with the ACCDB extension. The API call does work fine with
> the MDB extension. Clicking on an ACCDB file in Windows Explorer
> does work.

Interesting. A look under HKEY_CLASSES_ROOT
should tell something. I wonder if it has to do
with the 5-character extension. It's always been
the MS standard to use 3. It seems odd that they've
broken with that. Maybe FindExecutable is limited
to 3 characters and either finds no match or finds
two (if there's a .acc key)?



From: Mike Williams on

"mayayana" <mayaXXyana(a)rcXXn.com> wrote in message
news:eSxNCcHNKHA.1236(a)TK2MSFTNGP05.phx.gbl...

>> [Tony Toews said] The API call FindExecutable fails on
>> a file with the ACCDB extension. The API call does work
>> fine with the MDB extension. Clicking on an ACCDB file
>> in Windows Explorer does work.
>
> [Mayayana said] Interesting. A look under HKEY_CLASSES_ROOT
> should tell something. I wonder if it has to do with the
> 5-character extension. It's always been the MS standard to use 3.
> It seems odd that they've broken with that.

They can't have done, because long file extensions have been permitted for a
long time now and they use four or more characters a lot themselves these
days in their own extensions (docx, pptx, etc).

> Maybe FindExecutable is limited to 3 characters and either
> finds no match or finds two (if there's a .acc key)?

Actually I've just been trying a dozen or so different extensions (including
the OP's .accdb extension) by registering them with Windows in the normal
way so that they open by default with a specific program and all of them
work fine as far as Windows Explorer is concerned. However, the
FindExecutable function seems to have trouble with many of them. For
example, the following registered extensions produced the following result
when using the FindExecutable function:

.accdb FAILED
.abcde FAILED
.bcdef FAILED
.pqrst SUCCEEDED

There were all sorts of strange anomilies where certain file extensions were
found by FindExecutable and other file extensions were not, with (up to now)
no apparent ryhme or reason behind it. For example neither abcde nor pqrst
had any other extension registered with similar preceeding characters on my
machine, and in both cases the registry entry in HKCU after manually
registering them appeared identical, and yet one failed with FindExecutable
whereas the other succeeded. In all cases the file extension was found
properly by Windows Explorer and the file opened with the registered default
program when double clicked.

Unless I've missed something obvious I think this needs a little more
investigation.

Mike



From: Nobody on
"Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote in message
news:eshjXHJNKHA.504(a)TK2MSFTNGP06.phx.gbl...
>
> .accdb FAILED
> .abcde FAILED
> .bcdef FAILED
> .pqrst SUCCEEDED

I tested ".accdb" on Windows 98 and XP Pro. In Windows 98, it succeeded, in
XP Pro, it failed. I tried to restart XP just in case there is some caching
going on, but got the same result. I used all lower case letters, but I
tried renaming the file with all upper case, and using upper case in the
call, with the same failed result, so it's not a case issue. I guess we need
to upgrade to Windows 98. Here is my code:

Option Explicit

Private Const MAX_PATH = 260

Private Const SE_ERR_NOASSOC = 31
Private Const SE_ERR_FNF = 2 ' file not found
Private Const SE_ERR_PNF = 3 ' path not found
Private Const SE_ERR_OOM = 8 ' out of memory

Private Declare Function FindExecutable Lib "shell32.dll" Alias _
"FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String,
_
ByVal lpResult As String) As Long

Private Sub Form_Click()
Dim ret As Long
Dim sResult As String

sResult = String(100, 0)

ret = FindExecutable("C:\x.accdb", vbNullString, sResult)
Print "FindExecutable returned " & ret & ", LastDllError: " & _
Err.LastDllError
sResult = TrimNull(sResult)
Print "sResult: '" & sResult & "'"
End Sub

Private Function TrimNull(s As String) As String
Dim pos As Long

pos = InStr(s, Chr(0))

If pos <> 0 Then
TrimNull = Trim(Left(s, pos - 1))
Else
TrimNull = Trim(s)
End If

End Function



From: Tony Toews [MVP] on
"Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote:

>Actually I've just been trying a dozen or so different extensions (including
>the OP's .accdb extension) by registering them with Windows in the normal
>way so that they open by default with a specific program and all of them
>work fine as far as Windows Explorer is concerned. However, the
>FindExecutable function seems to have trouble with many of them.

Thanks for testing this. Glad it's not just me. <smile>

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
 |  Next  |  Last
Pages: 1 2
Prev: simple stopwach program
Next: Hex to Dec and vice versa