نوشته شده توسط
saeed.tgold
دوست عزیز کد شما تو خود برنامه کار میکنه درست اما وقتی نصب میکنم رو ویندوز نه اصلا هیچ عملی نمی کنه ! این کد رو تو general فرم مینویسم
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
و اینو تو image-click
ShellExecute Me.hwnd, "open", App.Path & "\Pic\gallery\1\1.jpg", vbNullString, vbNullString, vbNormalFocus
کد مشکلی نداشت، چک کنید که پوشه Pic\Gallery\1 در مسیر برنامه کامپایل شده وجود داشته باشه، اگر همچنان مشکل پابرجا بود نمونه سورس از مشکل هم ضمیمه تاپیک کنید
برای بررسی دقیق تر تابع زیر را بررسی کنید (در صورت بروز خطا پیام متناظر ظاهر میشه)
Public Sub Run(sPath$)
Dim iSERet%
iSERet% = ShellExecute(Me.hwnd, "open", sPath$, vbNullString, App.Path, vbNormalFocus)
Select Case iSERet:
Case 0: MsgBox "The operating system is out of memory or resources.", vbCritical
Case 2: MsgBox "The specified file was not found", vbCritical
Case 3: MsgBox "The specified path was not found.", vbCritical
Case 5: MsgBox "Windows 95 only: The operating system denied access to the specified file complete the operation.", vbCritical
Case 10: MsgBox "Wrong Windows version", vbCritical
Case 11: MsgBox "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).", vbCritical
Case 12: MsgBox "Application was designed for a different operating system", vbCritical
Case 13: MsgBox "Application was designed for MS-DOS 4.0", vbCritical
Case 15: MsgBox "Attempt to load a real-mode program", vbCritical
Case 16: MsgBox "Attempt to load a second instance of an application with non-readonly data segments", vbCritical
Case 19: MsgBox "Attempt to load a compressed application file", vbCritical
Case 20: MsgBox "Dynamic-link library (DLL) file failure", vbCritical
Case 26: MsgBox "A sharing violation occurred.", vbCritical
Case 27: MsgBox "The filename association is incomplete or invalid. because the request timed out.", vbCritical
Case 29: MsgBox "The DDE transaction failed.", vbCritical
Case 30: MsgBox "The DDE transaction could not be completed because other DDE transactions were being processed.", vbCritical
Case 31: MsgBox "There is no application associated with the given filename extension.", vbCritical
Case 32: MsgBox "Windows 95 only: The specified dynamic-link library was not found.", vbCritical
End Select
End Sub
برای مثال:
Private Sub Image1_Click()
Call Run(App.Path & "\Pic\gallery\1\1.jpg")
End Sub
موفق باشید