Results 1 to 6 of 6

Thread: GetCurrentDirectory API Problem

  1. #1

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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

  2. #2
    Member
    Join Date
    Feb 2001
    Location
    Greensboro, NC.
    Posts
    40

    Unhappy

    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

  3. #3

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    yeah, I'm just trying to sharpen my API skills that I dont have yet..

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  5. #5

    Thread Starter
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Young Buck, you da man. , that code was giving me fits, thanks again.

  6. #6
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width