Wednesday, April 29, 2009

Get Current Directory

'Get current directory

Private Declare Function GetCurrentDirectory
Lib "kernel32" _

Alias "GetCurrentDirectoryA" (ByVal nBufferLength
As Long, _

ByVal lpBuffer As String)
As Long



Private Sub Form_Paint()

Dim sSave As String

'create a buffer

sSave = String(255, 0)

'retrieve the current directory

GetCurrentDirectory 255, sSave

MsgBox sSave

End Sub



'Set current directory

Private Declare Function SetCurrentDirectory
Lib "kernel32" _

Alias "SetCurrentDirectoryA" (ByVal
lpPathName As String) As Long



Private Sub Form_Paint()

'set current directory for path of application

SetCurrentDirectory App.Path

End Sub






 

No comments:

Post a Comment