我有这个子来打开一个文件 - 它为文件选择了合适的应用程序,它运行良好:
Public Sub OpenNativeApp(ByVal psDocName As String)
' Opens the files psDocName in the appropriate application
Dim r As Long, msg As String
r = StartDoc(psDocName)
If r <= 32 Then
'There was an error
Select Case r
Case SE_ERR_FNF
msg = "File not found"
Case SE_ERR_PNF
msg = "Path not found"
Case SE_ERR_ACCESSDENIED
msg = "Access denied"
Case SE_ERR_OOM
msg = "Out of memory"
Case SE_ERR_DLLNOTFOUND
msg = "DLL not found"
Case SE_ERR_SHARE
msg = "A sharing violation occurred"
Case SE_ERR_ASSOCINCOMPLETE
msg = "Incomplete or invalid file association"
Case SE_ERR_DDETIMEOUT
msg = "DDE Time out"
Case SE_ERR_DDEFAIL
msg = "DDE transaction failed"
Case SE_ERR_DDEBUSY
msg = "DDE busy"
Case SE_ERR_NOASSOC
msg = "No association for file extension"
Case ERROR_BAD_FORMAT
msg = "Invalid EXE file or error in EXE image"
Case Else
msg = "Unknown error"
End Select
MsgBox msg
End If
End Sub
但是如何更改代码以便应用程序将自己置于屏幕的前面?
答案 0 :(得分:0)
是的,在这里你明白了:
私有函数StartDoc(psDocName As String)As Long Dim Scr_hDC As Long Scr_hDC = GetDesktopWindow() StartDoc = ShellExecute(Scr_hDC,“Open”,psDocName,“”,“C:\”,SW_SHOWNORMAL) 结束功能