Here some sample...
Code:Option Explicit Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long Private RetStr As String Private dl As Long Private DEFAULT_DRIVE As String Private DEFAULT_PATH As String Private Sub Dir1_Change() File1.Path = Dir1.Path End Sub Private Sub Drive1_Change() Dir1.Path = Drive1.Drive End Sub Private Sub Form_Load() 'Assumption: '1. You are refering to the DriveListBox, DirListBox control. '2. An ini file with name Directory.ini under the application directory. RetStr = String(255, Chr(0)) dl = GetPrivateProfileString("Directory", "Default", "C:", RetStr, Len(RetStr), App.Path & "\directory.ini") If dl <> 0 Then DEFAULT_PATH = Left(RetStr, InStr(1, RetStr, Chr(0), vbTextCompare) - 1) DEFAULT_DRIVE = Mid(DEFAULT_PATH, 1, 2) Drive1.Drive = DEFAULT_DRIVE Dir1.Path = DEFAULT_PATH End If End Sub




Reply With Quote