Loading ...
Sorry, an error occurred while loading the content.

46058Re: [libertybasic] Passing / Receiving large (64bit) parameters in API Calls

Expand Messages
  • Stefan Pendl
    Jan 18, 2013
      Am 18.01.2013 10:35, schrieb mike_collins_23:
      > Hi, I would like to use Liberty Basic to access a Vector Informatik dll (vxlapi.dll). Some of the calls require the transfer (or return) of a 64bit value (this is actually a bit mask). If parameters are passed on a stack to Windows API's then possibly 2 LONG parameters would look like a 64 bit value. The problem would still be how to handle the returned 64bit value ?
      > Any information would be appreciated.
      > Mike

      See the code below, which is used to get the free space of a drive.
      GetDiskFreeSpaceEx uses a LONG_INTEGER type, which is 64-bit.

      '---code start (watch for line wraps)

      i = 1
      while word$(Drives$, i) <> ""
      drive$ = word$(Drives$, i)
      print drive$; " ... "; GetDiskFreeSpace(drive$); " Bytes free"

      function GetDiskFreeSpace(driveLetter$)
      calldll #kernel32, "GetModuleHandleA" , _
      "kernel32.dll" as ptr, _
      hKernel as ulong

      calldll #kernel32, "GetProcAddress" , _
      hKernel as ulong, _
      "GetDiskFreeSpaceExA" as ptr, _
      pGetDiskFreeSpaceEx as ulong

      if pGetDiskFreeSpaceEx = 0 then
      struct lpSectorsPerCluster, value as ulong
      struct lpBytesPerSector, value as ulong
      struct lpNumberOfFreeClusters, value as ulong
      struct lpTotalNumberOfClusters, value as ulong

      calldll #kernel32, "GetDiskFreeSpaceA" , _
      driveLetter$ as ptr, _
      lpSectorsPerCluster as struct, _
      lpBytesPerSector as struct, _
      lpNumberOfFreeClusters as struct, _
      lpTotalNumberOfClusters as struct, _
      infoOK as ulong

      GetDiskFreeSpace = lpBytesPerSector.value.struct *
      lpSectorsPerCluster.value.struct * _
      struct lpFreeBytesAvailableToCaller, LowByte as ulong, HighByte
      as ulong
      struct lpTotalNumberOfBytes, LowByte as ulong, HighByte as ulong
      struct lpTotalNumberOfFreeBytes, LowByte as ulong, HighByte as

      calldll #kernel32, "GetDiskFreeSpaceExA" , _
      driveLetter$ as ptr, _
      lpFreeBytesAvailableToCaller as struct, _
      lpTotalNumberOfBytes as struct, _
      lpTotalNumberOfFreeBytes as struct, _
      infoOK as ulong

      GetDiskFreeSpace = lpTotalNumberOfFreeBytes.HighByte.struct *
      HexDec("100000000") + _
      end if
      end function

      '---code end

      Stefan Pendl

      LB 4.04 Pro ... http://www.libertybasic.com/assist.html
      LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

      LB Community Wiki .............. http://basic.wikispaces.com/
      LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
      LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

      Books at http://www.lulu.com/ and http://www.amazon.com/
      Alyce Watson ... APIs for Liberty BASIC
      Carl Gundel .... Beginning Programming with Liberty BASIC

      Windows 7 Home Premium 64-bit SP1
      AMD Turion X2 RM-70 2GHz, 4GB RAM
    • Show all 9 messages in this topic