2008-09-30 30 views

Respuesta

10

No parece haber una solución "fuera de la caja" para esta cosa.

Tomado de The Old Joel On Software Forums

De todas formas .. para poner este tema a descansar .. la siguiente era mi solución VB6: Me defino 2 símbolos en mi proyecto de VB "MPDEBUG" y "MPRELEASE" y llame a la siguiente función como la primera operación en la función de mi punto de entrada de aplicaciones.

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 
2

Will this work?

'Declaration 
Private Declare Function SetCurrentDirectory Lib "kernel32" _ 
Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long 

'syntax to set current dir 
SetCurrentDirectory App.Path 
+1

Pero es más simple utilizar los comandos nativos VB6 'ChDrive App.Path: ChDir App.Path' – MarkJ

6

solución que he encontrado que funciona utiliza un Sub Main, y comprueba si el programa se está ejecutando en el 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 
6

"El directorio actual parece ser el directorio de VB6" solo cuando abre un proyecto usando Archivo-Abrir.

Ábralo haciendo doble clic en el archivo .vbp mientras se cierra el IDE.

1

El directorio actual para cualquier programa, incluido vb6, se puede cambiar en las propiedades del acceso directo. Lo cambié a la raíz de mi árbol fuente, hace que usar File-Open sea más rápido.

Cuestiones relacionadas