[AccessD] ShellExecuteA

MartyConnelly martyconnelly at shaw.ca
Sun Dec 4 12:02:12 CST 2005


I don't know if this will help, but here are the general errors from 
shellexecute
There are some odd things that happen depending on folder options chosen 
under NTFS
File handles are held open behind the scenes by the OS for some period 
of time or maybe cached.
For example if you create a tree of folders and files via code and then 
proceed to delete them
you sometimes cannot delete the highest root directory created without a 
reboot.

'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp

'API STUFF 
====================================================================
Private Declare Function ShellExecute Lib "shell32.dll" Alias 
"ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As 
String, _
    ByVal lpParameters As String, ByVal lpDirectory As String, ByVal 
nShowCmd _
    As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
Private Const SE_ERR_ACCESSDENIED = 5
Private Const SE_ERR_ASSOCINCOMPLETE = 27
Private Const SE_ERR_DDEBUSY = 30
Private Const SE_ERR_DDEFAIL = 29
Private Const SE_ERR_DDETIMEOUT = 28
Private Const SE_ERR_DLLNOTFOUND = 32
Private Const SE_ERR_FNF = 2
Private Const SE_ERR_NOASSOC = 31
Private Const SE_ERR_OOM = 8
Private Const SE_ERR_PNF = 3
Private Const SE_ERR_SHARE = 26

'strProgram is the name of a program to run, or a file to open
'EX: calc.exe or c:\test.doc or http:\\www.microsoft.com
Public Sub RunProgram(strProgram As String)
    Dim lRet As Long    ' Get the return value
   
    ' Execute the API call
    lRet = ShellExecute(vbNull, "", strProgram, "", "", SW_SHOWNORMAL)
   
    ' If ShellExecute works it will return a number greate than 32
    ' Otherwise call our ReportError function to see what went wrong
    If lRet <= 32 Then
        ReportShellExecuteError (lRet)
    End If
End Sub

Private Sub ReportShellExecuteError(lErrNum As Long)
    Dim strErr As String
    Select Case lErrNum
        Case ERROR_FILE_NOT_FOUND
            strErr = "The specified file was not found."
        Case ERROR_PATH_NOT_FOUND
            strErr = "The specified path was not found."
        Case ERROR_BAD_FORMAT
            strErr = "The .exe file is invalid (non-Win32® .exe or error 
in .exe image)."
        Case SE_ERR_ACCESSDENIED
            strErr = "The operating system denied access to the 
specified file. "
        Case SE_ERR_ASSOCINCOMPLETE
            strErr = "The file name association is incomplete or invalid."
        Case SE_ERR_DDEBUSY
            strErr = "The DDE transaction could not be completed because 
other DDE transactions were being processed."
        Case SE_ERR_DDEFAIL
            strErr = "The DDE transaction failed."
        Case SE_ERR_DDETIMEOUT
            strErr = "The DDE transaction could not be completed because 
the request timed out."
        Case SE_ERR_DLLNOTFOUND
            strErr = "The specified dynamic-link library was not found. "
        Case SE_ERR_FNF
            strErr = "The specified file was not found. "
        Case SE_ERR_NOASSOC
            strErr = "There is no application associated with the given 
file name extension. This error will also be returned if you attempt to

print a file that is not printable."
        Case SE_ERR_OOM
            strErr = "There was not enough memory to complete the 
operation."
        Case SE_ERR_PNF
            strErr = "The specified path was not found."
        Case SE_ERR_SHARE
            strErr = "A sharing violation occurred."
    End Select
   
    MsgBox strErr, vbExclamation, "Error running program"
End Sub


Dan Waters wrote:

>Jurgen,
>
>If you're still having problems, can you open the file from your screen
>using a hyperlink?  I've always had good luck with this method.  If you have
>the path to the file, that's all you need to get started.
>
>Dan Waters
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of J?rgen Welz
>Sent: Saturday, December 03, 2005 1:38 PM
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] ShellExecuteA
>
>Hey Stuart:
>
>Permissions are set in tightly regulated profiles that are cloned from a 
>standard set.  IT is regenerating profiles for all users of my application 
>as there has been some rare corruption in the past.
>
>I had never personally had explorer fail to open a .pee file but when I had 
>the IT person try my login, it failed for him.  The most difficult aspect of
>
>this is the apparent random nature of the problem.  Some people have fewer 
>problems and they vary from day to day and in the course of a day.
>
>The application with which we have a difficulty has an application which is 
>supposedly required for file management and stores stats and other meta data
>
>regarding the 1000's of files we create every year.  We have never used the 
>features of this application because the Access application does all the 
>file management and gives us a far more flexible means of managing our data.
>
>  I discovered that this component of the system has not yet correctly been 
>installed as the license manager software does not permit this component to 
>load.  I now suspect that the "File not Found" return from both ShellExecute
>
>(value is 2 -  Marty) and the Win Explorer interface relates to storing meta
>
>data in this component of the application.
>
>IT installed this upgrade 4 weeks ago on a Friday night and on Saturday I 
>received a panic call that no one could open any .Pee files.  The file 
>format changed from v9.1 to 9.2 and had to upgrade some 20,000 thousand 
>files needed for access to needed and potentially needed data.  And their 
>year end is Oct 31.  There is a tool that upgrades all files below a user 
>defined sub folder, but this crashed hundreds of times so I wound up taking 
>it in ever smaller chunks.  I now suspect that the crashes were due to the 
>failure to sucessfully install the component that collects the data about 
>the files.  What a great way to negotiate a new job and wage...
>
>
>Ciao
>Jürgen Welz
>Edmonton, Alberta
>jwelz at hotmail.com
>
>
>
>
>
>  
>
>>From: "Stuart Sanders" <lists at bitshk.com>
>>
>>Hi Jurgen,
>>
>>Taking a complete stab in the dark here, but since you mentioned this is a
>>locked down terminal services environment, is it possible there are user
>>permission issues on the upgraded application?
>>
>>Stuart
>>    
>>
>
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list