Mail Archives: djgpp/1997/09/18/06:03:53
This is a multi-part message in MIME format.
--------------53E117097FF4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
from: csantill AT lausd DOT k12 DOT ca DOT us
How come I can never get __dpmi_free_memory information or
_go32_dpmi_free_mem_info to return the correct mem installed
& mem free? I'm always of a meg or two. The 2nd part if the
program is just HD space check which works correctly.
--------------53E117097FF4
Content-Type: text/plain; charset=us-ascii; name="Sys_chk.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Sys_chk.c"
#include <stdio.h>
#include <dos.h>
#include <dpmi.h>
#include <conio.h>
int main(void)
{
// Disk characteristics structure
struct dfree ds;
// Mem characteristics structure
__dpmi_free_mem_info info;
// Temp values of needed data
unsigned long int free_s,tot_s,used_s,free_m,tot_m,used_m;
// Get disk characteristics
getdfree(3,&ds);
// Get mem characteristics
while(__dpmi_get_free_memory_information(&info)!=0);
// Calc disk info
tot_s=ds.df_total*ds.df_sclus*ds.df_bsec;
free_s=ds.df_avail*ds.df_sclus*ds.df_bsec;
used_s=tot_s-free_s;
// Calc mem info
free_m=info.total_number_of_free_pages*4096;
tot_m=info.total_number_of_physical_pages*4096;
used_m=tot_m-free_m;
// Print mem info
printf("\n\n\n\n\n\n\n"
"+-------------------------------------+\n"
"| Physical RAM Stats on this computer |\n"
"| |\n"
"| Total Bytes Installed: %U\n"
"| Total KiloBytes Installed: %U\n"
"| Total MegaBytes Installed: %U\n"
"| |\n"
"| Bytes Used: %U\n"
"| KiloBytes Used: %U\n"
"| MegaBytes Used: %U\n"
"| |\n"
"| Bytes Free: %U\n"
"| KiloBytes Free: %U\n"
"| MegaBytes Free: %U\n"
"+-------------------------------------+\n\n\n\n\n\n",
tot_m,
tot_m/1024,
(tot_m/1024)/1024,
used_m,
used_m/1024,
(used_m/1024)/1024,
free_m,
free_m/1024,
(free_m/1024)/1024);
getch();
// Print disk info
printf("\n\n\n\n\n----------------------------------\n"
"Disk Space Stats on drive C:\n\n"
"Total Clusters: %U\n"
"Sectors per Cluster: %U\n"
"Bytes per Sector: %U\n\n"
"Available Clusters: %U\n\n"
"Total Bytes: %U\n"
"Total KiloBytes: %U\n"
"Total MegaBytes: %U\n\n"
"Free Bytes: %U\n"
"Free KiloBytes: %U\n"
"Free MegaBytes: %U\n\n"
"Used Bytes: %U\n"
"Used KiloBytes: %U\n"
"Used MegaBytes: %U\n"
"----------------------------------\n\n\n",
ds.df_total,
ds.df_sclus,
ds.df_bsec,
ds.df_avail,
tot_s,
tot_s/1024,
(tot_s/1024)/1024,
free_s,
free_s/1024,
(free_s/1024)/1024,
used_s,
used_s/1024,
(used_s/1024)/1024);
getch();
return 0;
}
--------------53E117097FF4--
- Raw text -