delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/17/18:03:32

From: csantill AT lausd DOT k12 DOT ca DOT us
Message-ID: <342053F7.67F3@lausd.k12.ca.us>
Date: Wed, 17 Sep 1997 15:04:39 -0700
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Getting a size unknown error w/dpmi.h struct

This is a multi-part message in MIME format.

--------------78F87B9FCF8
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

from: csantill AT lausd DOT k12 DOT ca DOT us

I want to be able to detect the available memory in my programs
using _go32_dpmi_get_free_memory_information but the I try init
a struct to hold the information received from the func but
I get a 'size unknown' error at compilation. Here's my source:

--------------78F87B9FCF8
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;

//***************************************************//
// This line gives me the storage size unknown error //
  struct _go32_dpmi_meminfo m; //********************//
//***************************************************//

// 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
  _go32_dpmi_get_free_memory_information(&m);

// 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.available_physical_pages*4096;
  tot_m=info.total_physical_pages*4096;
  used_m=tot_m-free_m;

//-----------------------------------
  printf("\n\n\n\n\n"
         "%D - Avail mem bytes\n"
         "%D - Avail pgs\n"
         "%D - Avail phys pgs\n"
         "%D - Tot phys pgs\n",
         m.available_memory,
         m.available_pages,
         m.available_physical_pages,
         m.total_physical_pages);
  getch();
//-----------------------------------
// Print mem info
  printf("\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"
         "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;

}

--------------78F87B9FCF8--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019