Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
U_long
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Re: U_long
Miscellaneous
Thread ID:
00511591
Message ID:
00511783
Views:
18
>I just read somewhere that an integer is a u_long... Can that be correct?
>
Mike,

Here is the type definition from the Windows Platform SDK
typedef union _ULARGE_INTEGER { 
  struct {
      DWORD LowPart; 
      DWORD HighPart; 
  };
  ULONGLONG QuadPart;
} ULARGE_INTEGER, *PULARGE_INTEGER;
LowPart specifies the low order 32 bits, HighPart the high order. Here's a demonstration of how you would use it.
DECLARE INTEGER GetDiskFreeSpaceEx IN Win32API;
  STRING @lpDirectoryName, STRING @lpFreeBytesAvailable,;
  STRING @lpTotalNumberOfBytes, STRING @lpTotalNumberOfFreeBytes
lcdir = "C:\"
STORE REPLICATE(CHR(0), 8) TO lcavailable, lctotal, lcfree
? GetDiskFreeSpaceEx(@lcdir, @lcavailable, @lctotal, @lcfree)
? StringToInteger(lctotal)
? StringToInteger(lcfree)

FUNCTION StringToInteger
    
    LPARAMETER pcstring, plsigned
    
    LOCAL lnresult, lnlast, lni, llsigned,;
      lnmsb, lnmax
    lnresult = 0
    lnlast = LEN(pcstring)
    * Return Signed Integer?
    IF PCOUNT() = 2
      llsigned = plsigned
    ELSE
      llsigned = .F.
    ENDIF
    FOR lni = 1 TO lnlast
      lnresult = lnresult + ASC(SUBSTR(pcstring, lni, 1)) * (256 ^ (lni - 1))
    NEXT
    IF llsigned
      lnmsb = (lnlast * 8) - 1
      IF BITTEST(lnresult, lnmsb)
        lnmax = (2 ^ (lnmsb + 1))
        lnresult = lnresult - lnmax
      ENDIF
    ENDIF
    RETURN lnresult
ENDFUNC
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform