English
C ++ Forum

Completed: DiskFree/DiskSize & GetDiskFreeSpace

 

Michael
Dell
Hello Sebastian,

Have there one small trouble discover and of course in all versions of Prf2Cpp.
the whole concerns The functions DiskFree/DiskSize as well as The API GetDiskFreeSpaceExA.

DiskFree/DiskSize runs on WinXP lovely but not Win98.
GetDiskFreeSpaceExA runs on both Systemen not. (suspect the it was with the byte function To do has.)

here one demonstration:
CompileMarkSeparation
!Def GFDS_lwTyp(1)          SubStr$(LW_Typ($(1)),2,">  ")
Def GFDS_DskSpaceGesamt(1) Val(SubStr$(SubStr$($(1),2,"|||"),1,"||"))
Def GFDS_DskSpaceFrei(1)   Val(SubStr$(SubStr$($(1),2,"|||"),2,"||"))
Def GFDS_DskSpaceBelegt(1) Val(SubStr$(SubStr$($(1),2,"|||"),3,"||"))

Proc ShowIt

    Parameters txt$
    Print
    Print SubStr$(txt$,1,"|||")
    Print ("      "+Format$("###,##0.00",Round(Div(GFDS_DskSpaceGesamt(txt$),1000000),2))+"  Mb  gesamt")
    Print ("      "+Format$("###,##0.00",Round(Div(GFDS_DskSpaceFrei(txt$),1000000),2))+"  Mb  frei")
    Print ("      "+Format$("###,##0.00",Round(Div(GFDS_DskSpaceBelegt(txt$),1000000),2))+"  Mb  belegt")
    Print
    Print

EndProc

Proc LW_Typ

    Parameters LW$
    Def LaufwerksTyp(1)       !"KERNEL32.DLL","GetDriveTypeA"
    Declare LW#,LW_Typ&
    Dim LW#,Add(Len(LW$),1)
    String LW#,0 = LW$
    LW_Typ& = LaufwerksTyp(LW#)
    Dispose LW#
    Case Equ(LW_Typ&,0): Return LW$+">  keine Ahnung"
    Case Equ(LW_Typ&,1): Return LW$+">  nicht vorhanden"
    Case Equ(LW_Typ&,2): Return LW$+">  Diskette"
    Case Equ(LW_Typ&,3): Return LW$+">  Festplatte"
    Case Equ(LW_Typ&,4): Return LW$+">  Netz Laufwerk"
    Case Equ(LW_Typ&,5): Return LW$+">  CD/DVD"
    Case Equ(LW_Typ&,6): Return LW$+">  RAM"
    Return "Fehler!"

EndProc

Proc GetDiskFreeSpace

    Parameters gDS_LW$
    Declare Gesamt!,Belegt!,gFrei!
    Clear Gesamt!,Belegt!,gFrei!
    gDS_LW$ = (Left$(gDS_LW$,3) + Chr$(0))
    DiskFree(gDS_LW$)
    DiskSize(gDS_LW$)
    Gesamt! = DiskSize(gDS_LW$)
    gFrei!  = DiskFree(gDS_LW$)
    Belegt! = (Gesamt! - gFrei!)
    Return (GFDS_lwTyp(gDS_LW$)+"|||"+ Str$(Gesamt!) + "||" + Str$(gFrei!) + "||" + Str$(Belegt!))

EndProc

Proc old_GetDiskFreeSpace

    Parameters Path$
    Declare LWtyp$
    Def GetDiskFreeSpaceEx(4) !"KERNEL32.DLL","GetDiskFreeSpaceExA"
    Def x!(8) (((((((%(8)*256+%(7))*256+%(6))*256+%(5))*256+%(4))*256+%(3))*256+%(2))*256+%(1))
    Declare Path#,AvBytes#,TotalBytes#,FreeBytes#,frei!,gesamt!,avb!,erg$
    Dim Path#,255
    Dim AvBytes#,8
    Dim TotalBytes#,8
    Dim FreeBytes#,8
    String Path#,0 = Path$
    GetDiskFreeSpaceEx(Path#,AvBytes#,TotalBytes#,FreeBytes#)
    gesamt! = x!(Byte(TotalBytes#,0),Byte(TotalBytes#,1),
    Byte(TotalBytes#,2),Byte(TotalBytes#,3),
    Byte(TotalBytes#,4),Byte(TotalBytes#,5),
    Byte(TotalBytes#,6),Byte(TotalBytes#,7))
    frei!   = x!(Byte(FreeBytes#,0),Byte(FreeBytes#,1),
    Byte(FreeBytes#,2),Byte(FreeBytes#,3),
    Byte(FreeBytes#,4),Byte(FreeBytes#,5),
    Byte(FreeBytes#,6),Byte(FreeBytes#,7))
    avb!    = Sub(gesamt!,frei!)
    gesamt! = Round(gesamt!,0)
    frei!   = Round(frei!,0)
    avb!    = Round(avb!,0)
    erg$ = "|||"+Str$(gesamt!)+"||"+Str$(frei!)+"||"+Str$(avb!)
    erg$ = GFDS_lwTyp(Path$) + erg$
    Dispose AvBytes#
    Dispose TotalBytes#
    Dispose FreeBytes#
    Dispose Path#
    Return erg$

EndProc

**** Programm- Source ****
Cls
Print "Mit qDiskFree/DiskSizeq"
ShowIt(GetDiskFreeSpace("C:"))
ShowIt(GetDiskFreeSpace("D:"))
Print "Mit qGetDiskFreeSpaceExAq"
ShowIt(old_GetDiskFreeSpace("C:"))
ShowIt(old_GetDiskFreeSpace("D:"))
WaitInput
End
 
Salu Michael...

Hab zwar krumme Fieß awer dofir e' ecklich Gsicht! 
08/28/06  
 




Sebastian
König
Hello Michael,

thanks for Info and the Testcode!

The problem with the Variante with GetDiskFreeSpaceExA() lying when calling the function x!(): C++ using there to Berechnung no Fließkomma-Arithmetik separate simply Integer. unfortunately can not so simply Change, there it itself hold circa a reinen Integer-expression deals. there's but glücklicherweise a very einfachen Workaround : If you in the DEFinition simply @!() instead of @%() verwendest, ought to it sowohl with XProfan as well as with Profan2Cpp correctly. functions...

because of the thing with DiskFree/DiskSize login I later again

MfG

Sebastian
 
Windows XP, XProfan/Profan² 4.5 bis 11
Profan2Cpp-Homepage:  [...] 
Alte Profan²-Seite:  [...] 
08/28/06  
 




Michael
Dell
thanks, the functions

that I the again not Geschnallt Have, I ought to me well More concentrate.
 
Salu Michael...

Hab zwar krumme Fieß awer dofir e' ecklich Gsicht! 
08/28/06  
 




Sebastian
König
[quote:1b6b11ce43]thanks, the functions [/quote:1b6b11ce43]
OK, super

now to the others trouble: as cause suspect I, I in of my Implementierung of DiskFree() only thanks, the functions GetDiskFreeSpace() use. moreover standing in the Remarks-Sektion in the MSDN, that it under Win95/98 Problems with Laufwerkskapazitäten > 2GB gives... in the next Beta-Version (The I well tommorrow Upload will be) I will the time on GetDiskFreeSpaceEx() adjust...

MfG

Sebastian
 
Windows XP, XProfan/Profan² 4.5 bis 11
Profan2Cpp-Homepage:  [...] 
Alte Profan²-Seite:  [...] 
08/28/06  
 




Sebastian
König
Hello Michael,

straight have I Version 1.5.9f uploaded (and what's more on this Posting appended ). functions @DiskFree() and @DiskSize() so now too under windows 98 correctly?

MfG

Sebastian

2.777 kB
Hochgeladen:08/29/06
Downloadcounter51
Download
 
Windows XP, XProfan/Profan² 4.5 bis 11
Profan2Cpp-Homepage:  [...] 
Alte Profan²-Seite:  [...] 
08/29/06  
 




Michael
Dell
Hello Sebastian,

runs lovely!!! thanks
 
Salu Michael...

Hab zwar krumme Fieß awer dofir e' ecklich Gsicht! 
08/30/06  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

2.330 Views

Untitledvor 0 min.

Themeninformationen

this Topic has 2 subscriber:

Sebastian König (3x)
Michael Dell (3x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie