>Only change seems to be to replace CDECL with SDECL
Actually, I think the correct replacement would be to use the DISKSIZE() and DISKFREE() functions. (PB 7+ or maybe 8+).
Announcement
Collapse
No announcement yet.
Removeable drive address
Collapse
X
-
The CDECL code was pasted from the forum years ago when the old code for
QB and maybe PBdos would only use long variables so ??? and the full size of the disk was never correct
once the GB drives got past 2gb. It did work
for PBdll6. But as I said the replacement code probably works on all versions.
I found the routine here (searching for it a few minutes ago). Only change seems to be to replace CDECL with SDECL which is
noted so it was originally CDECL
Last edited by Fred Buffington; 24 Aug 2008, 12:13 PM.
Leave a comment:
-
>The following works in pbdll version 6+ but gives a negative 900+ mB
For purposes of comparison (IF, SELECT CASE), 32-bit integers were handled signed starting in PB/Win 7x.
Prior to that LONG & DWORD word were treated 'sign the same' (might have been signed, might have been unsigned) e.g., -1& and 0xFFFFFFFF would compare 'equal' using either syntax.
In 7x/8x 'SELECT CASE AS LONG' uses sign-agnostic 32-bit comparisons. Don't know about 9x. (yet).
(No the change was not documented).
Leave a comment:
-
> CALL DWORD pGetDiskFreeSpaceEx CDECL ....
CDECL? Not in either my SDK doc nor in PB-supplied Win32API.INC
And this works?
???
Style points only, from SDK description for GetDiskFreeSpaceEx ...
It is not necessary to call LoadLibrary on Kernel32.dll because it is already loaded into every process address space
Leave a comment:
-
There are routines for getting the freespace/total space on a drive.
Once you know that is is removeable #2? then if it's 128M or greater (125M or greaer for zip drive) then
chances are it's a flash drive (or zip drive perhaps) rather than a floppy.
If you get an error or 0's then chances are it's a floppy with no floppy in it.
Would that work ?
The following works in pbdll version 6+ but gives a negative 900+ mB or more for total space on pbwin 8+ ????
although the available space seems ok on pbwin 8. Even the C: drive shows wrong in version 8 for total space
Code:#COMPILE EXE 'Kev Peel, Member 'posted September 05, 2005 06:38 PM #INCLUDE "win32api.inc" DECLARE SUB showfreesp(dv$) DECLARE FUNCTION dvDiskFree&&(BYVAL DSK$,typ$) '------------------------------------------------------------------------------ ' Display available drive letters and each drive type '------------------------------------------------------------------------------ FUNCTION PBMAIN LOCAL n AS LONG, buffer AS STRING, zDrive AS ASCIIZ * 32, sOutput AS STRING LOCAL removabledrives& DIM rdrives$(10) ' Obtain a list of drives from the system... buffer = STRING$(2048, $NUL) buffer = LEFT$(buffer, GetLogicalDriveStrings(LEN(buffer), BYVAL STRPTR(buffer))) ' Build a list of drives + types... FOR n = 1 TO PARSECOUNT(buffer, $NUL)-1 zDrive = PARSE$(buffer, $NUL, n) SELECT CASE GetDriveType(zDrive) CASE %DRIVE_FIXED: sOutput = sOutput + zDrive + $TAB + $TAB + "Fixed" + $CRLF ' count&=count&+1 ' rdrives$(count&)=UCASE$(MID$(LTRIM$(zdrive),1,1)) CASE %DRIVE_REMOTE: sOutput = sOutput + zDrive + $TAB + $TAB + "Remote" + $CRLF CASE %DRIVE_REMOVABLE: sOutput = sOutput + zDrive + $TAB + $TAB + "Removable" + $CRLF count&=count&+1 rdrives$(count&)=MID$(LTRIM$(zdrive),1,1) ' msgbox "zdrive="+zdrive + " " + rdrives$(count&) CASE %DRIVE_CDROM: sOutput = sOutput + zDrive + $TAB + $TAB + "CD-ROM" + $CRLF CASE %DRIVE_RAMDISK: sOutput = sOutput + zDrive + $TAB + $TAB + "RAMDISK" + $CRLF CASE ELSE: sOutput = sOutput + zDrive + $TAB + $TAB + "Unknown Type" + $CRLF END SELECT NEXT n ' Display the information... MSGBOX sOutput, %MB_ICONINFORMATION, "Available Drives" ' msgbox "removeabledrives&="+rdrives$(1)+" "+rdrives$(2) 'str$(removeabledrives&) FOR dnum&=1 TO count& 'msgbox rdrives$(dnum&) showfreesp(rdrives$(dnum&)) NEXT END FUNCTION SUB showfreesp(dv$) 'EXPORT DIM freesp AS CURRENCY 'DWORD DIM totlsp AS CURRENCY 'DWORD 'dv$=COMMAND$ IF dv$="" THEN EXIT SUB 'dv$="C" freesp=dvDiskFree&&(dv$,"F") totlsp=dvDiskFree&&(dv$,"T") MSGBOX "total sp="+STR$(totlsp) msg$="Free Space on "+dv$+CHR$(9)+FORMAT$(freesp,"##,###,###,###")+" bytes" IF VAL(FORMAT$(totlsp,"###########"))<>0 THEN msg$=msg$+$CRLF+"Out of:"+CHR$(9)+CHR$(9)+FORMAT$(totlsp,"##,###,###,###")+" bytes" END IF SLEEP 500 MSGBOX msg$,,"Drive Space" END SUB FUNCTION dvDiskFree&&(BYVAL DSK$,typ$) 'EXPORT DIM pGetDiskFreeSpaceEx AS DWORD PTR ' Returns the number of free bytes on selected drive LOCAL d AS ASCIIZ * 4 LOCAL sc AS DWORD LOCAL bs AS DWORD LOCAL fc AS DWORD LOCAL tc AS DWORD Drive% = ASC(UCASE$(Dsk$)) IF Drive% < 65 OR Drive% > 90 THEN Drive% = 0 IF Drive% THEN d = CHR$(Drive%) + ":\" ELSE d = CURDIR$ END IF Done% = 0 hLib& = LoadLibrary("KERNEL32.DLL") IF hLib& THEN pGetDiskFreeSpaceEx = GetProcAddress(hLib&, "GetDiskFreeSpaceExA") IF pGetDiskFreeSpaceEx THEN CALL DWORD pGetDiskFreeSpaceEx CDECL (d, lpFreeBytesAvailableToCaller&&, _ lpTotalNumberOfBytes&&, lpTotalNumberOfFreeBytes&&) IF typ$="F" THEN FUNCTION = lpFreeBytesAvailableToCaller&& ELSE FUNCTION = lpTotalNumberOfBytes&& MSGBOX STR$(lpTotalNumberOfBytes&&) END IF Done% = -1 END IF CALL FreeLibrary(hLib&) END IF IF NOT Done% THEN IF ISTRUE(GetDiskFreeSpace(d, sc, bs, fc, tc)) THEN IF typ$="F" THEN FUNCTION = CQUD(sc * bs * fc) END IF END IF END IF END FUNCTION
Code:hLib& = LoadLibrary("KERNEL32.DLL") IF hLib& THEN pGetDiskFreeSpaceEx = GetProcAddress(hLib&, "GetDiskFreeSpaceExA") IF pGetDiskFreeSpaceEx THEN CALL DWORD pGetDiskFreeSpaceEx CDECL (d, lpFreeBytesAvailableToCaller&&, _ lpTotalNumberOfBytes&&, lpTotalNumberOfFreeBytes&&) IF typ$="F" THEN FUNCTION = lpFreeBytesAvailableToCaller&& ELSE FUNCTION = lpTotalNumberOfBytes&& END IF Done% = -1 END IF CALL FreeLibrary(hLib&) END IF
Code:lResult&=GetDiskFreeSpaceEx(d, lpFreeBytesAvailableToCaller&&, _ lpTotalNumberOfBytes&&, lpTotalNumberOfFreeBytes&&) IF typ$="F" THEN FUNCTION = lpFreeBytesAvailableToCaller&& ELSE FUNCTION = lpTotalNumberOfBytes&& END IF
Of course with the console compilers simply replace the MSGBOX statement(s) with a PRINT statement and WAITKEY$.Last edited by Fred Buffington; 17 Aug 2008, 10:02 AM.
Leave a comment:
-
Originally posted by Jack Lyon View PostI need code or tool to establish the address of any attached usb flash drive for creating backups from PBCC 4.04
Now I need to know how to identify a removable drive as a floppy. Drive A could be a USB device if floppy does not exist.
Leave a comment:
-
I'm not sure what you mean by "address" but you might search the forum for "getdrivetype"
There's several examples that go through the alphabet and returns what kind of drive is associated with it's drive letter.
Leave a comment:
-
Removeable drive address
I need code or tool to establish the address of any attached usb flash drive for creating backups from PBCC 4.04Tags: None
Leave a comment: