原程序如下:
Private Declare Function GetWindowsDirectory Lib "Kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function WaitForSingleObject Lib "Kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "Kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000
Sub Main()
ChDrive App.Path
ChDir App.Path
If App.PrevInstance Then
'MsgBox ("不可重复运行!"), vbExclamation
End
End If
Form1.Show 1
Dim PRGpath1
Dim wb As String
Dim wp As Integer
Dim winpath As String
Dim h As Long
Dim I As Long
Dim r As Long
Dim p As Long
Dim sysfile4 As String
PRGpath1 = CurDir()
wb = Space(260)
wp = GetWindowsDirectory(wb, Len(wb))
winpath = Left(wb, wp)
SaveSetting "PFILE", "SET", "PRGpath", PRGpath1
sysfile4 = Dir(PRGpath1 + "\PFILE.exe")If sysfile4 = "" Then
MsgBox (curpath1 + "目录中缺少系统文件" + Chr(13) + Chr(10) + "PFILE.exe,请与作者联系!" + Chr(13) + Chr(10) + "系统无法运行!!"), vbExclamation
End
End If
I = Shell(winpath + "\PFILE.exe", vbNormalFocus)
p = OpenProcess(SYNCHRONIZE, False, I)
r = WaitForSingleObject(p, INFINITE)
r = CloseHandle(p)
End Sub
Private Declare Function GetWindowsDirectory Lib "Kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function WaitForSingleObject Lib "Kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "Kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000
Sub Main()
ChDrive App.Path
ChDir App.Path
If App.PrevInstance Then
'MsgBox ("不可重复运行!"), vbExclamation
End
End If
Form1.Show 1
Dim PRGpath1
Dim wb As String
Dim wp As Integer
Dim winpath As String
Dim h As Long
Dim I As Long
Dim r As Long
Dim p As Long
Dim sysfile4 As String
PRGpath1 = CurDir()
wb = Space(260)
wp = GetWindowsDirectory(wb, Len(wb))
winpath = Left(wb, wp)
SaveSetting "PFILE", "SET", "PRGpath", PRGpath1
sysfile4 = Dir(PRGpath1 + "\PFILE.exe")If sysfile4 = "" Then
MsgBox (curpath1 + "目录中缺少系统文件" + Chr(13) + Chr(10) + "PFILE.exe,请与作者联系!" + Chr(13) + Chr(10) + "系统无法运行!!"), vbExclamation
End
End If
I = Shell(winpath + "\PFILE.exe", vbNormalFocus)
p = OpenProcess(SYNCHRONIZE, False, I)
r = WaitForSingleObject(p, INFINITE)
r = CloseHandle(p)
End Sub
你是不是想得到应用程序运行路径?
应该这样写
PRGpath1 = App.Path
n=1,2,3...
然后再运行看看是在那一句出的错
然后再判断
先别可是
不管怎么说,你写的PRGpath1 = CurDir()这句话是不是想得到应用程序运行路径?
如果是那肯定没错改成PRGpath1 = App.Path 就行了.