I'm new to perl and I've been trying to code GlobalMemoryStatusEx in a perl script but I haven't had any luck, any help would be appreciated, here is my code
use warnings; use Win32::API; use Win32::API::Struct; use Data::Dumper; use strict; Win32::API::Struct->typedef(MEMORYSTATUSEX { DWORD dwLength; DWORD dwMemoryLoad; DWORDLONG ullTotalPhys; DWORDLONG ullAvailPhys; DWORDLONG ullTotalPageFile; DWORDLONG ullAvailPageFile; DWORDLONG ullTotalVirtual; DWORDLONG ullAvailVirtual; DWORDLONG ullAvailExtendedVirtual; }); Win32::API->Import( 'kernel32', 'VOID GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer); + my $stat = Win32::API::Struct->new('MEMORYSTATUSEX', lpBuffer); GlobalMemoryStatusEx($stat); my $dwLength = FormatBytes( $stat->{dwLength} ); print "Size of memory status structure: $dwLength\n"; $dwTotalPhys = FormatBytes( $stat->{ullTotalPhys} ); print "Total Available physical memory --> ullTotalPhys\n\n"; printf "Memory in use: %ld%%\n", $stat->{dwMemoryLoad}; my $dwTotalPhys = FormatBytes( $stat->{dwTotalPhys} ); print "Total physical memory --> $dwTotalPhys\n"; my $dwAvailPhys = FormatBytes( $stat->{ullAvailPhys} ); print "Free physical memory ---> ullAvailPhys \n"; my $dwTotalVirtual = FormatBytes( $stat->{ullTotalVirtual} ); print "Total virtual memory ---> $ullTotalVirtual \n"; my $dwAvailVirtual = FormatBytes( $stat->{ullAvailVirtual} ); print "Free virtual memory ----> $ullAvailVirtual\n"; my $dwTotalPageFile = FormatBytes( $stat->{ullTotalPageFile} ); print "Total paging file ------> $ullTotalPageFile\n"; my $dwAvailPageFile = FormatBytes( $stat->{ullAvailPageFile} ); print "Free paging file -------> $ullAvailPageFile\n\n";
Thanks for any help.

In reply to 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.