#pragma warning( disable:4001 ) // Disable single line comment warning /////////////////////////////////////////////////////////////////////////////////////////////////// // // FILE: FREEDISK.C (compiled using Visual C++) // (c) 1996 Guillaume Dargaud // // PURPOSE: This DLL provides a way for a LabWindows/CVI program to check for available disk size // This is meant to be used on Windows 3.1 with MS C ver 1.5 and CVI 32 bits // // NOTE: All exported functions that reference variables in the dll or call functions // that reference variables in the dll should probably be declared with __loadds // and __far to load the dll's data segment on entry since there is no pagination // in CVI. They should also be declared as extern and __export since they are // part of a DLL. And finally they should be __cdecl against compilation in C++. // // CONTROL MACROS: _LOGFILE: writes information in the log file INTERRUPT.C // _DEBUG: compilation done in debugger mode. Controls expansion of // misc macros such as TRACE, ASSERT... // // PROJECT FILES: FREEDISK.C, FREEDISK.DEF // // COMPILATION: I recommend the following parameters in DEBUG mode (used for simulation): // Compiler: /nologo /G2 /FPi87 /W4 /Zi /ALw /Od /D "_DEBUG" // /D "_LOGFILE" /FR /GD /Fd"INTERRUPT.PDB" // Linker: /NOLOGO /LIB:"oldnames" /LIB:"libw" /LIB:"ldllcew" // /NOD /NOE /PACKC:61440 /ALIGN:16 /CO /MAP:FULL // Resources: _DEBUG // // I recommend the following parameters in RELEASE mode (used for real time acquisition): // Compiler: /nologo /Gs /G3 /FPi87 /W3 /ALw /O1 // /D "NDEBUG" /D "NLOGFILE" /FR /GD // Linker: /NOLOGO /LIB:"oldnames" /LIB:"libw" /LIB:"ldllcew" // /NOD /NOE /PACKC:61440 /ALIGN:16 /ONERROR:NOEXE // Resources: NDEBUG // // You can then recompile everything for the simulation mode by just selecting // the MSVC menu [Options][Project] and the Build Mode [Debug]. // In the same way, use the Build Mode [Release] for creating a real time DLL /////////////////////////////////////////////////////////////////////////////////////////////////// #include #include "DiskFree.h" ///////////////////////////////////////////////////////////////////////////// // FUNCTION: AvailableDiskSize() // PURPOSE: Return available space on disk in bytes // IN: DiskNum: 1 for A: 2 for B:... ///////////////////////////////////////////////////////////////////////////// unsigned long PREFIX AvailableDiskSize( unsigned char DiskNum ) { union _REGS inregs, outregs; inregs.h.ah = 0x36; // Get disk free space inregs.h.dl = DiskNum; _intdos( &inregs, &outregs ); if (outregs.x.ax==0xFFFF) return 0; return (long)outregs.x.ax*outregs.x.bx*outregs.x.cx; }