Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does VB support this control.....
Message
 
À
20/02/2002 03:40:48
Information générale
Forum:
Visual Basic
Catégorie:
Contrôles ActiveX
Divers
Thread ID:
00622388
Message ID:
00622425
Vues:
17
Use ShellExecute:
Option Explicit

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

Private Sub Command1_Click()
Dim lngResult As Long

    lngResult = ShellExecute(Me.hwnd, "open", Text1.Text, vbNullString, "", SW_SHOWNORMAL)

    'If the function fails, the return value is an error value that is less than or equal to 32.
    If lngResult >= 33 Then Exit Sub
    
    Select Case lngResult
        Case 0
            MsgBox "The operating system is out of memory or resources."
        Case ERROR_FILE_NOT_FOUND
            MsgBox "Le document est introuvable."
        Case ERROR_PATH_NOT_FOUND
            MsgBox "Le chemin d'accès est introuvable."
        Case ERROR_BAD_FORMAT
            MsgBox "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image)."
        Case SE_ERR_ACCESSDENIED
            MsgBox "The operating system denied access to the specified file."
        Case SE_ERR_ASSOCINCOMPLETE
            MsgBox "The filename association is incomplete or invalid."
        Case SE_ERR_DDEBUSY
            MsgBox "The DDE transaction could not be completed because other DDE transactions were being processed."
        Case SE_ERR_DDEFAIL
            MsgBox "The DDE transaction failed."
        Case SE_ERR_DDETIMEOUT
            MsgBox "The DDE transaction could not be completed because the request timed out."
        Case SE_ERR_DLLNOTFOUND
            MsgBox "The specified dynamic-link library was not found."
        Case SE_ERR_FNF
            MsgBox "The specified file was not found."
        Case SE_ERR_NOASSOC
            MsgBox "Ce type de document n'est pas ASSOCIÉ à une application dans Windows."
        Case SE_ERR_OOM
            MsgBox "There was not enough memory to complete the operation."
        Case SE_ERR_PNF
            MsgBox "The specified path was not found."
        Case SE_ERR_SHARE
            MsgBox "A sharing violation occurred."
    End Select
End Sub
>Hi,
>
>I would like to know did VB support to reterive the windows file type mapping table to open any different kind of files?
>let say, if i had a file "abc.ppt" , then i just need to type in the path of the file name, the powerpoint will open this file?
>
>
>Wai
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform