Thanks for all the help because of the help I was able to code the perl script, but it does not return any values. Does anyone now why?
use warnings; use Win32::API; use Win32::API::Struct; use Data::Dumper; use Win32::SystemInfo; use strict; typedef Win32::API::Struct MEMORYSTATUSEX => qw{ DWORD dwLength; DWORD dwMemoryLoad; DWORDLONG ullTotalPhys; DWORDLONG ullAvailPhys; DWORDLONG ullTotalPageFile; DWORDLONG ullAvailPageFile; DWORDLONG ullTotalVirtual; DWORDLONG ullAvailVirtual; DWORDLONG ullAvailExtendedVirtual; }; Win32::API->Import( 'kernel32', 'BOOL GlobalMemoryStatusEx( LPMEMORYSTATUSEX lpBuffer +)' ); my $stat = Win32::API::Struct->new( 'MEMORYSTATUSEX' ); GlobalMemoryStatusEx($stat); my $dwLength = FormatBytes( $stat->{dwLength} ); print "\nSize of memory status structure: $dwLength\n"; my $ullTotalPhys = FormatBytes( $stat->{ullTotalPhys} ); print "Total Available physical memory --> $ullTotalPhys\n\n"; printf "Memory in use: %ld%%\n", $stat->{dwMemoryLoad}; my $ullAvailPhys = FormatBytes( $stat->{ullAvailPhys} ); print "Free physical memory ---> $ullAvailPhys \n"; my $ullTotalVirtual = FormatBytes( $stat->{ullTotalVirtual} ); print "Total virtual memory ---> $ullTotalVirtual \n"; my $ullAvailVirtual = FormatBytes( $stat->{ullAvailVirtual} ); print "Free virtual memory ----> $ullAvailVirtual\n"; my $ullTotalPageFile = FormatBytes( $stat->{ullTotalPageFile} ); print "Total paging file ------> $ullTotalPageFile\n"; my $ullAvailPageFile = FormatBytes( $stat->{ullAvailPageFile} ); print "Free paging file -------> $ullAvailPageFile\n\n"; #--------------------------------------------------------------------- +------ # sub FormatBytes { my( $Number ) = @_; my( $Suffix ) = ""; my $K = 1024; my $M = 1024 * $K; my $G = 1024 * $M; if( $G <= $Number ) { $Suffix = "(G)"; $Number /= $G; } elsif( $M <= $Number ) { $Suffix = "(M)"; $Number /= $M; } elsif( $K <= $Number ) { $Suffix = "(K)"; $Number /= $K; } $Number =~ s/(\.\d{0,2})\d*$/$1/; {} while ($Number =~ s/^(-?\d+)(\d{3})/$1,$2/); return( $Number . $Suffix ); } #--------------------------------------------------------------------- +------
As I looked for answers in the web I found a lot of questions on how to do this with perl, unfortunately I have not been successful.

In reply to Re^2: How do I code GlobalMemoryStatusEx in perl by azaragoza
in thread How do I code GlobalMemoryStatusEx in perl by azaragoza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.