R
Rafsun82
Guest
How to retrieve hard drive partition information in Game Maker by using
Hard Disk Info
extension by Rafsun82
Hard Disk Info
extension by Rafsun82
GM Version: GM8 and GM:S
Target Platform: Windows
Download: Download from Dropbox (ZIP)
Links: Original Website Post
Summary:
By following this tutorial, you will learn how to get hard drive partition information in Game Maker. Like- total partition number, drive letter, volume label, total size, total frees pace, drive type and drive format. You need to download a extension package Hard Disk Info written by me. Link is posted above.
An example GMK file, extension package GEX file and a manual HTML file is included in the download.
Tutorial:
Download the ZIP archive. Extract it. Install and add the extension package (named HardDIskInfo.gex) to your Game Maker 8 or Game Maker: Studio project.
Note: Check the manual file to learn about available functions in the extension and how to use them.
In this tutorial, we want that the game to draw all partitions information in the screen. Like this -
And also want that the game should response when we insert a drive (Ex- Removal disk) in the computer.
So, simply we will create a variable named "text" and all information will be put in there with decoration. Then we will draw this to the screen in draw event.
At first create a script named "make_list". This will fetch all information and decorate them as a string and put the string in the variable "text".
Codes in the script should look like-
Code:
{
n = hdd_count()-1;
text = "";
for ( i =0; i <= n; i += 1;)
{
text += hdd_letter(i)+" "+hdd_label(i)+" ("+hdd_type(i)+") ("+hdd_format(i)+")#";
text += string(hdd_convert( hdd_freespace(i), 1))+" GB free of "+string(hdd_convert( hdd_size(i), 1))+" GB#";
text += "#";
}
}
Now, in the Create event declare "text" variable first then call the "make_list" script. Then in the Draw event, simply draw the string values of "text". Run the game and if everything okay, we can proceed to next.
We want that if a removal disk is inserted then the game should draw it's information too. In the create event add this code:
Code:
old_total = hdd_count();
Code:
if hdd_count() != old_total
{
make_list();
old_total = hdd_count();
}
Run the game. Then insert a drive and notice the change in the screen. Then remove it again. The screen will change again.
If something went wrong, follow all the steps from the beginning again. Or don't mind to post a reply. Thanks for using it. Sorry for any grammatical or spelling mistake. If this tutorial is helpful Like this post.
There is my website if you have time - http://r82.net23.net/home.
Last edited by a moderator: