• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 6 رای - 2.17 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: Retrieve File Association and open a file in its native application
حالت موضوعی
#1
کد:
Private Declare Function FindExecutable Lib "shell32" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal sResult As String) As Long
    Private Const MAX_PATH As Long = 260
    Private Const ERROR_FILE_NO_ASSOCIATION As Long = 31
    Private Const ERROR_FILE_NOT_FOUND As Long = 2
    Private Const ERROR_PATH_NOT_FOUND As Long = 3
    Private Const ERROR_FILE_SUCCESS As Long = 32 'my constant
    Private Const ERROR_BAD_FORMAT As Long = 11
    Dim mflg As Boolean
    Public ActiveClientName As String
    Function retassoc(fn As String, fpath As String) As String
    ' retrieve the associated program that uses this file
    Dim success As Long
    Dim pos As Long
    Dim sResult As String
    sResult = Space$(MAX_PATH)
    success = FindExecutable(fn, fpath, sResult)
    pos = InStr(sResult, Chr$(0))
    If pos Then
    retassoc = Left$(sResult, pos - 1)
    End If
    End Function
    Function LoadUserFile(ByVal FN2Load As String)
    On Error GoTo load_err
    ' load the file in its' native application
    For x = Len(FN2Load) To 0 Step -1
    If Mid(FN2Load, x, 1) = "\" Then
    opPath = Left(FN2Load, x)
    opFile = Right(FN2Load, Len(FN2Load) - x)
    Exit For
    End If
    Next
    Call Shell(retassoc(opFile, opPath) & " " & Chr(34) & FN2Load & Chr(34), vbNormalFocus)
    Exit Function
    load_err:
    MsgBox "The file you are trying to open apparently has no program association available" & vbCrLf & "or it is a corrupted file. I can't open " & opFile, vbInformation + vbOKOnly, "Error occured on file open"
    On Error GoTo 0
    End Function
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  Copy a File Quickly Amin_Mansouri 2 2,498 09-24-2022، 12:46 PM
آخرین ارسال: jgreenlee
  Open File Binary And Search String In Files Amin_Mansouri 1 2,885 01-24-2017، 04:15 PM
آخرین ارسال: aminjannoukaretam
  سورس Open\Close CD\DVD Ram Thewolf 0 1,773 06-19-2012، 09:35 PM
آخرین ارسال: Thewolf
  استفاده از شی File System Object در ویژوال بیسیک Ghoghnus 0 1,978 04-24-2012، 06:54 PM
آخرین ارسال: Ghoghnus
  حل مشکل باز نشدن فایل های space دار و رفع پیغام file not found Amin_Mansouri 0 3,320 08-29-2011، 04:17 PM
آخرین ارسال: Amin_Mansouri
  Delete File Amin_Mansouri 0 2,203 05-10-2011، 05:06 PM
آخرین ارسال: Amin_Mansouri
  Source code Insert & Delete data from a file Amin_Mansouri 0 2,551 04-29-2011، 03:56 PM
آخرین ارسال: Amin_Mansouri
  Source Code Burn Iso File Amin_Mansouri 0 2,360 04-19-2011، 11:38 AM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان