home *** CD-ROM | disk | FTP | other *** search
- Code Section A
-
- Sub Main()
- æThis is where our initialisation
- æcode would go, if we had any
- End Sub
-
-
- Code Section B
-
- Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long æall one line
-
- Global Const gintMAX_SIZE% = 255
- Global Const gstrNULL$ = ""
-
- Sub AddDirSep(strPathName As String)
- If Right$(RTrim$(strPathName), Len(gstrSEP_DIR)) <> gstrSEP_DIR Then
- strPathName = RTrim$(strPathName) & gstrSEP_DIR
- End If
- End Sub
-
- Function StripTerminator(ByVal strString As String) As String
- Dim intZeroPos As Integer
-
- intZeroPos = InStr(strString, Chr$(0))
- If intZeroPos > 0 Then
- StripTerminator = Left$(strString, intZeroPos - 1)
- Else
- StripTerminator = strString
- End If
- End Function
-
- Function UCase16(ByVal str As String)
- #If Win16 Then
- UCase16 = UCase$(str)
- #Else
- UCase16 = str
- #End If
- End Function
-
-
- Code Section C
-
- Public Property Get Created() As Date
- Created = datCreated
- End Property
-
-
- Code Section D
-
- Private datCreated As Date
-
-
- Code Section E
-
- Public Function GetWindowsDir() As String
- Dim strBuf As String
-
- strBuf = Space$(gintMAX_SIZE)
-
- 'Get the windows directory and then trim the buffer to the exact length
- 'returned and add a dir sep (backslash) if the API didn't return one
-
- If GetWindowsDirectory(strBuf, gintMAX_SIZE) > 0 Then
- strBuf = StripTerminator$(strBuf)
- AddDirSep strBuf
-
- GetWindowsDir = UCase16(strBuf)
- Else
- GetWindowsDir = gstrNULL
- End If
- End Function
-
-
- Code Section F
-
- Private Sub Command1_Click()
- Dim x As GetDir.WindowsLocation
-
- Set x = New GetDir.WindowsLocation
- MsgBox t.Created
- End Sub
-
-
- Code Section G
-
- Private y As Object
-
-
- Code Section H
-
- Private Sub Command2_Click()
- Set y = CreateObject("GetDir.WindowsLocation")
- Text1.TEXT = y.GetWindowsDir
- End Sub
-