Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
FindExecutable API call fails for ACCDB file extensions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tony Toews [MVP]  
View profile  
 More options Sep 13 2009, 1:50 am
Newsgroups: microsoft.public.vb.general.discussion
From: "Tony Toews [MVP]" <tto...@telusplanet.net>
Date: Sat, 12 Sep 2009 23:50:03 -0600
Local: Sun, Sep 13 2009 1:50 am
Subject: FindExecutable API call fails for ACCDB file extensions
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/


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mayayana  
View profile  
 More options Sep 13 2009, 9:36 am
Newsgroups: microsoft.public.vb.general.discussion
From: "mayayana" <mayaXXy...@rcXXn.com>
Date: Sun, 13 Sep 2009 09:36:47 -0400
Local: Sun, Sep 13 2009 9:36 am
Subject: Re: FindExecutable API call fails for ACCDB file extensions

> 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)?

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Williams  
View profile  
 More options Sep 13 2009, 12:47 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Mike Williams" <M...@WhiskyAndCoke.com>
Date: Sun, 13 Sep 2009 17:47:20 +0100
Local: Sun, Sep 13 2009 12:47 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions

"mayayana" <mayaXXy...@rcXXn.com> wrote in message

news:eSxNCcHNKHA.1236@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


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nobody  
View profile  
 More options Sep 13 2009, 2:39 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Nobody" <nob...@nobody.com>
Date: Sun, 13 Sep 2009 14:39:21 -0400
Local: Sun, Sep 13 2009 2:39 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions
"Mike Williams" <M...@WhiskyAndCoke.com> wrote in message

news:eshjXHJNKHA.504@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


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Toews [MVP]  
View profile  
 More options Sep 13 2009, 3:30 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Tony Toews [MVP]" <tto...@telusplanet.net>
Date: Sun, 13 Sep 2009 13:30:57 -0600
Local: Sun, Sep 13 2009 3:30 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions

"Mike Williams" <M...@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/


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nobody  
View profile  
 More options Sep 13 2009, 3:51 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Nobody" <nob...@nobody.com>
Date: Sun, 13 Sep 2009 15:51:12 -0400
Local: Sun, Sep 13 2009 3:51 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions
It seems that FindExecutable() is unreliable for extensions with more than 3
letters. Here is a version based on AssocQueryString(), this function
doesn't require an existing file:

Option Explicit

Private Const MAX_PATH = 260

'  AssocQueryString
Enum ASSOCF
    ASSOCF_INIT_NOREMAPCLSID = &H1
    ASSOCF_INIT_BYEXENAME = &H2
    ASSOCF_OPEN_BYEXENAME = &H2
    ASSOCF_INIT_DEFAULTTOSTAR = &H4
    ASSOCF_INIT_DEFAULTTOFOLDER = &H8
    ASSOCF_NOUSERSETTINGS = &H10
    ASSOCF_NOTRUNCATE = &H20
    ASSOCF_VERIFY = &H40
    ASSOCF_REMAPRUNDLL = &H80
    ASSOCF_NOFIXUPS = &H100
    ASSOCF_IGNOREBASECLASS = &H200
End Enum
Enum ASSOCSTR
    ASSOCSTR_COMMAND = 1
    ASSOCSTR_EXECUTABLE
    ASSOCSTR_FRIENDLYDOCNAME
    ASSOCSTR_FRIENDLYAPPNAME
    ASSOCSTR_NOOPEN
    ASSOCSTR_SHELLNEWVALUE
    ASSOCSTR_DDECOMMAND
    ASSOCSTR_DDEIFEXEC
    ASSOCSTR_DDEAPPLICATION
    ASSOCSTR_DDETOPIC
    ASSOCSTR_INFOTIP
    ASSOCSTR_QUICKTIP
    ASSOCSTR_TILEINFO
    ASSOCSTR_CONTENTTYPE
    ASSOCSTR_DEFAULTICON
    ASSOCSTR_SHELLEXTENSION
    ASSOCSTR_MAX
End Enum
Private Declare Function AssocQueryString Lib "shlwapi.dll" Alias _
    "AssocQueryStringA" (ByVal flags As ASSOCF, ByVal str As ASSOCSTR, _
    ByVal pszAssoc As String, ByVal pszExtra As String, _
    ByVal pszOut As String, ByRef pcchOut As Long) As Long

Private Sub Form_Load()
    Debug.Print "GetAssociatedEXE: '" & GetAssociatedEXE(".accdb") & "'"
End Sub

Private Function GetAssociatedEXE(sExtension As String) As String
    Dim ret As Long
    Dim sResult As String
    Dim pcchOut As Long

    sResult = String(MAX_PATH, 0)
    pcchOut = Len(sResult)

    ret = AssocQueryString(0, ASSOCSTR_EXECUTABLE, sExtension, "open", _
        sResult, pcchOut)
    Debug.Print "AssocQueryString returned " & ret & ", LastDllError: " & _
        Err.LastDllError
    If ret = 0 Then
        ' AssocQueryString succeeded
        sResult = TrimNull(sResult)
        GetAssociatedEXE = sResult
    End If
End Function

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


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Williams  
View profile  
 More options Sep 13 2009, 4:21 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Mike Williams" <M...@WhiskyAndCoke.com>
Date: Sun, 13 Sep 2009 21:21:28 +0100
Local: Sun, Sep 13 2009 4:21 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions
"Nobody" <nob...@nobody.com> wrote in message

news:OMU2RuKNKHA.508@TK2MSFTNGP06.phx.gbl...

> It seems that FindExecutable() is unreliable for extensions with more than
> 3 letters. Here is a version based on
> AssocQueryString(), this function doesn't require an
> existing file:

Thanks. That works fine. I did actually notice the reference to
AssocQueryString when I was checking the details for FindExecutable on:

http://msdn.microsoft.com/en-us/library/bb776419(VS.85).aspx

According to that page you should use FindExecutable if you want to retrieve
the executable associated with a document file and AssocQueryString if you
want to find the path of an executable. Since FindExecutable (when it
works!) actually does return the path and filename of the executable
associated with a document then I assumed AssocQueryString was designed to
be used to return the full path of a registered executable when you passed
it only the name of the executable, and so I never gave it a try. Thanks for
the clarification and the code.

I really do wish that Micro$oft would learn to write help files in such a
way that they do actually help people!

Mike


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl E. Peterson  
View profile  
 More options Sep 16 2009, 4:53 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Karl E. Peterson" <k...@exmvps.org>
Date: Wed, 16 Sep 2009 13:53:56 -0700
Local: Wed, Sep 16 2009 4:53 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions

Nobody wrote:
> It seems that FindExecutable() is unreliable for extensions with more than 3
> letters. Here is a version based on AssocQueryString(),

Have you found it unreliable in any manner other than not returning an answer?  (I'm
assuming it's not returning a *wrong* answer, is it?)  I'm thinking, maybe call the
routine with FindExecutable first, then fall back to AssocQueryString if that first
one doesn't work.  Reason being, AssocQueryString requires IE5 on older systems
(NT4/9x) and you resported (in another post) that FindExecutable seems to work okay
at 98?
--
.NET: It's About Trust!
 http://vfred.mvps.org

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nobody  
View profile  
 More options Sep 17 2009, 2:23 am
Newsgroups: microsoft.public.vb.general.discussion
From: "Nobody" <nob...@nobody.com>
Date: Thu, 17 Sep 2009 02:23:34 -0400
Local: Thurs, Sep 17 2009 2:23 am
Subject: Re: FindExecutable API call fails for ACCDB file extensions
"Karl E. Peterson" <k...@exmvps.org> wrote in message
news:%23J71P$wNKHA.352@TK2MSFTNGP02.phx.gbl...

> Nobody wrote:
>> It seems that FindExecutable() is unreliable for extensions with more
>> than 3
>> letters. Here is a version based on AssocQueryString(),

> Have you found it unreliable in any manner other than not returning an
> answer?  (I'm assuming it's not returning a *wrong* answer, is it?)  I'm
> thinking, maybe call the routine with FindExecutable first, then fall back
> to AssocQueryString if that first one doesn't work.  Reason being,
> AssocQueryString requires IE5 on older systems (NT4/9x) and you resported
> (in another post) that FindExecutable seems to work okay at 98?

I don't know if AssocQueryString is always reliable, I don't use it often,
but FindExecutable works with 4 letters extensions(ACCDB) on Windows 98, but
not on XP.

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Toews [MVP]  
View profile  
 More options Oct 22 2009, 6:09 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Tony Toews [MVP]" <tto...@telusplanet.net>
Date: Thu, 22 Oct 2009 16:09:00 -0600
Subject: Re: FindExecutable API call fails for ACCDB file extensions

"Nobody" <nob...@nobody.com> wrote:
>It seems that FindExecutable() is unreliable for extensions with more than 3
>letters.

So Karl wrote an article on this topic.  Classic VB Corner
Finding an Associated Executable

After using a given API for a decade or more, you tend to just take it
for granted that it works. Karl Peterson shows how he worked around a
challenge when it didn't.

http://visualstudiomagazine.com/articles/2009/10/13/finding-an-associ...

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/
For a free, convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl E. Peterson  
View profile  
 More options Oct 22 2009, 6:54 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Karl E. Peterson" <k...@exmvps.org>
Date: Thu, 22 Oct 2009 15:54:05 -0700
Local: Thurs, Oct 22 2009 6:54 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions

Tony Toews [MVP] wrote:
> "Nobody" <nob...@nobody.com> wrote:

>>It seems that FindExecutable() is unreliable for extensions with more than 3
>>letters.

> So Karl wrote an article on this topic.  Classic VB Corner
> Finding an Associated Executable

> After using a given API for a decade or more, you tend to just take it
> for granted that it works. Karl Peterson shows how he worked around a
> challenge when it didn't.

> http://visualstudiomagazine.com/articles/2009/10/13/finding-an-associ...

Yes, Tony beat me back here...  Thanks to all in this thread for the inspiration on
that one!  What a weird twisted little error that was, huh?
--
.NET: It's About Trust!
 http://vfred.mvps.org

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Toews [MVP]  
View profile  
 More options Oct 22 2009, 7:07 pm
Newsgroups: microsoft.public.vb.general.discussion
From: "Tony Toews [MVP]" <tto...@telusplanet.net>
Date: Thu, 22 Oct 2009 17:07:10 -0600
Local: Thurs, Oct 22 2009 7:07 pm
Subject: Re: FindExecutable API call fails for ACCDB file extensions
"Karl E. Peterson" <k...@exmvps.org> wrote:

>Yes, Tony beat me back here...  Thanks to all in this thread for the inspiration on
>that one!  What a weird twisted little error that was, huh?

Sure would be nice to know why it was so inconsistent.

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/
For a free, convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google