Pas*_*dis 11
对于这件事,它似乎不是一个"开箱即用"的解决方案.
无论如何..把这个话题放在一边..以下是我的VB6解决方案:我在我的VB项目"MPDEBUG"和"MPRELEASE"中定义了2个符号,并将以下函数作为我的apps入口点函数中的第一个操作.
Public Sub ChangeDirToApp()
#If MPDEBUG = 0 And MPRELEASE = 1 Then
' assume that in final release builds the current dir will be the location
' of where the .exe was installed; paths are relative to the install dir
ChDrive App.path
ChDir App.path
#Else
' in all debug/IDE related builds, we need to switch to the "bin" dir
ChDrive App.path
ChDir App.path & BackSlash(App.path) & "..\bin"
#End If
End Sub
Run Code Online (Sandbox Code Playgroud)
解决方案,我发现工程使用a Sub Main,并检查程序是否在IDE中运行.
Dim gISIDE as Boolean
Sub Main()
If IsIDE Then
ChDrive App.Path
ChDir App.Path
End If
' The rest of the code goes here...
End Sub
Public Function IsIDE() As Boolean '
IsIDE = False
'This line is only executed if running in the IDE and then returns True
Debug.Assert CheckIDE
If gISIDE Then
IsIDE = True
End If
End Function
Private Function CheckIDE() As Boolean ' this is a helper function for Public Function IsIDE()
gISIDE = True 'set global flag
CheckIDE = True
End Function
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20379 次 |
| 最近记录: |