-
I'm getting this error:
"Can't find DLL Entry Point GetCurrentDirectory in Kernel32
Anyone know why, here's my code
Code:
'Option Explicit
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Private Declare Function GetCurrentDirectory Lib "kernel32" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Const DRIVE_CDROM = 5
Const DRIVE_FIXED = 3
Const DRIVE_RAMDISK = 6
Const DRIVE_REMOTE = 4
Const DRIVE_REMOVABLE = 2
Private Sub cmdExit_Click()
End
End Sub
Private Sub Drive1_Change()
'Dim driveType As Long
'Dim freeSpace As Long, Sectors As Long
'Dim Bytes As Long
'Dim freeClusters As Long, totalClusters As Long
'Dim retValue As Long
'Dim buffer As String * 255
'Dim DName As String
Screen.MousePointer = vbHourglass
DoEvents
DName = Left(Drive1.Drive, 2) & "\"
driveType = GetDriveType(DName)
Select Case driveType
Case 0
lblDrive = "UNDETERMINED"
Case DRIVE_REMOVABLE
lblDrive = "REMOVABLE"
Case DRIVE_FIXED
lblDrive = "FIXED"
Case DRIVE_REMOTE
lblDrive = "REMOTE"
Case DRIVE_CDROM
lblDrive = "CDROM"
Case DRIVE_RAMDISK
lblDrive = "RAMDISK"
End Select
' Get free space
retValue = GetDiskFreeSpace(DName, Sectors, Bytes, freeClusters, totalClusters)
lblFreeDiskSpace = Sectors * Bytes * freeClusters
' Get current directory
retValue = GetCurrentDirectory(255, buffer)
lblCurrentDir = buffer
' Get windows directory
retValue = GetWindowsDirectory(buffer, 255)
lblWindowsDir = buffer
Screen.MousePointer = vbDefault
DoEvents
Debug.Print App.Path
End Sub
Private Sub Form_Load()
Drive1_Change
End Sub
-
I did notice that you left out the Alias, but that proved irrelevant. I am getting the same error.
Have you thought about using CurDir([Drive]) Function?
It accomplishes pretty much the same thing.
Regards
-
yeah, I'm just trying to sharpen my API skills that I dont have yet..:)
-
what's up Lethal,
Try this declaration instead ......
Code:
Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
should work fine now.
-
Young Buck, you da man. :D, that code was giving me fits, thanks again.
-
No problem Lethal goto www.allapi.net and download their API viewer, you can't trust the VB API Loader, alot of the declarations are wrong.