Jump to content


Photo

Cdmmemory Dll


  • Please log in to reply
8 replies to this topic

#1 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 13 April 2007 - 11:40 AM

Ok, before you all post criticism such as "this has been done before", I was reluctant to post this topic, but people were asking me for the source, so I posted it. May I make a few things clear before I show the source.

1. This source is largely uncommented. I wasn't expecting to release it
2. Please, if you make something with this, give me credit. The readme in the ZIP applies to the DLL and it's source.
3. Please do not copy this and turn it into a DLL and then have the audacity to claim it as your own.

Credits: cdm319 (me), Roach (for teaching me C++), Porfirio (for helping me with C++ when I started)

Source:
#define export extern "C" __declspec (dllexport) // contained in header file, but so you know how to export
#include "dll.h" // this is replaced by your default dll header file, which includes the above code
#include "windows.h"


export double cdm_ram_percent()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double rampercent;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       rampercent = pt1.dwMemoryLoad;
       
       return rampercent;
}

export double cdm_ram_total()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double ramtotal;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       ramtotal = pt1.dwTotalPhys;
       
       return ramtotal;
}

export double cdm_ram_avail()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double ramavail;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       ramavail = pt1.dwAvailPhys;
       
       return ramavail;
}
       
export double cdm_page_total()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double pagetotal;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       pagetotal = pt1.dwTotalPageFile;
       
       return pagetotal;
}

export double cdm_page_avail()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double pageavail;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       pageavail = pt1.dwAvailPageFile;
       
       return pageavail;
}

export double cdm_virtual_total()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double virtotal;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       virtotal = pt1.dwTotalVirtual;
       
       return virtotal;
}
                                   
export double cdm_virtual_avail()
{
       MEMORYSTATUS pt1;
       MEMORYSTATUS *pt2;
       double viravail;
       
       pt1.dwLength = sizeof(MEMORYSTATUS);

       pt2 = &pt1;

       GlobalMemoryStatus(pt2);
       
       viravail = pt1.dwAvailVirtual;
       
       return viravail;
}
      

Link:
cdmMemory DLL

Happy coding :D

Edited by cdm319, 13 April 2007 - 11:49 AM.

  • 0

Chris Matthews, Co-Leader of Digital X

#2 zedman1000

zedman1000

    GMC Member

  • New Member
  • 715 posts

Posted 05 October 2007 - 07:18 AM

I dont care if no-one posts here, your brilliant.
  • 0

#3 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 05 October 2007 - 08:05 AM

Unforetunately, I would have used this if Delphi doesn't have much simpler functions for getting this info <_< .
Still, great work when considering it's in c/c++.
  • 0

#4 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 05 October 2007 - 08:22 PM

These functions are easy enough uuf6429... But thanks for the replies.
  • 0

Chris Matthews, Co-Leader of Digital X

#5 flea rowen

flea rowen

    GMC Member

  • New Member
  • 13 posts

Posted 24 December 2007 - 12:21 AM

thank's a lot...this is what i was searching...but...what are the total page file and the page file free?? thanks...
  • 0

#6 Bram Buurlage

Bram Buurlage

    GMC Member

  • New Member
  • 51 posts

Posted 24 December 2007 - 03:54 PM

@ flea rowen: page file is the region of your harddisk that is used as if it where ram.

@ cdm319
i got a linker error when i compile ( i use dev-cpp )
you know how to fix that?

the error:
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status

edit: lol i fixed it myself, by putting it into a project :D

Edited by Bram Buurlage, 24 December 2007 - 04:00 PM.

  • 0

#7 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 24 December 2007 - 05:11 PM

flea rowen
I would advise using my "System Information" DLL instead, as it has more functions.

Bram Buurlage
Thanks.

Everyone
Please do not bump this topic up, it is basically useless now.
  • 0

Chris Matthews, Co-Leader of Digital X

#8 flea rowen

flea rowen

    GMC Member

  • New Member
  • 13 posts

Posted 25 December 2007 - 05:43 PM

i have tried it but it gave me same strange error...for example it change me a variable....may be because i use a variable named global.user but this dll is perfect for what i need...
  • 0

#9 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 26 December 2007 - 11:54 PM

flea rowen
global.user is already used. My SystemInfo DLL is perfect for what you need. Now please, do not bump this topic any more. PM me if you have further questions.
  • 0

Chris Matthews, Co-Leader of Digital X