Jump to content


Photo

Get Drives Dll


  • Please log in to reply
24 replies to this topic

#1 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 13 January 2007 - 06:15 PM

Hey everyone,
I have spent all day today and most of last night working on this DLL. It is my second DLL in C++, my first was released here yesterday.

This DLL returns all the installed drives on a user's PC. It is easier to work with than IsmAvatar's I think because it returns each drive separately, rather than all the drive letters in one string. However, IsmAvatar's is much faster than mine. So, use whatever suits you.

Note to everyone: Read the readme.txt file carefully about credit and how you can use the DLL.

Download Get Drives DLL ZIP

DLL cannot be used in system information programs

Edited by cdm319, 06 June 2008 - 01:14 PM.

  • 0

Chris Matthews, Co-Leader of Digital X

#2 juju1828

juju1828

    GMC Member

  • New Member
  • 35 posts

Posted 13 January 2007 - 06:54 PM

This good but you need to have only one script...that is way to many scripts...I will write one for you real quick.
  • 0

#3 juju1828

juju1828

    GMC Member

  • New Member
  • 35 posts

Posted 13 January 2007 - 08:26 PM

Alright I made this script for you that will do all those drives in one script and this script also will initialize the dll functions on only the first run of the script.

Here is the script:
/* 
This script created by JL Services, Inc.
 Visit us at http://jlservice.net

Arguments:
  0 - This can be either a string or a real value.
      If you choose to use a real value the value
      the value must be between 1 and 26 (including
      those numbers).  That is for the corresponding
      letter in the alphabet.
      If you choose to use a string, this script will
      only recgonize the first letter in the string.
      
Returns:
    This script will return either a 0 (false) or 1 (true)
*/

//First initialize the dll functions
if (variable_global_exists("checka")=false)
    {
    _i=1;
    while (_i < 27)
        {
        execute_string("global.check"+chr(96+_i)+"=external_define("+chr(34)+"GetDrives.dll"+chr(34)+","+chr(34)+"cdm_"+chr(96+_i)+"drive"+chr(34)+",dll_cdecl,ty_string,0);")
        _i+=1;
        }
    }

//Setup variables
_arg0 = argument0;
_method = 0;
_result = 0;

//Argument Check
if (is_string(_arg0) = true)
    {
    _method = 1;
    }
    
if (_method = 0)
    {
    if (_arg0 < 1 or _arg0 > 26)
        {
        //This error will get returned is the real value is x<1 or x>26
        show_error("drive_check - argument0 out of bounds - real - Value provided: ["+string(_arg0)+"]",0);
        show_message("Defaulting back to value [1]");
        _arg0 = 1;
        }
    }

if (_method = 1)
    {
    _arg0 = string_lower(_arg0); //Make all the letters the same case
    if (string_length(_arg0) < 1)
        {
        //This error will get returned if there is nothing in the string
        show_error("drive_check - argument0 out of bounds - string - Value provided: ["+_arg0+"] - String length: ["+string(string_length(_arg0))+"]",0);
        show_message("Defaulting back to value [a]");
        _arg0 = "a";
        }
    if (string_length(_arg0) > 1)
        {
        _arg0 = string_copy(_arg0,0,1); //Getting only the first letter
        }
    }
//END Argument Check

//Argument Processing
if (_method = 1)
    {
    _arg0 = ord(_arg0)-96;
    _method = 0;
    }

if (_method = 0)
    {
    _result = external_call(variable_global_get("check"+chr(96+_arg0)));
    if (_result="true")
        {
        return true;
        }else{
        return false;
        }
    }

Also, to better get an understanding of how to use this script I edited the gm6 file to run with the script and display the drives that are available.

Download

If there are any questions, please see my signature for the contact information.

Edited by juju1828, 13 January 2007 - 08:29 PM.

  • 0

#4 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 13 January 2007 - 09:15 PM

thanks, but for the noobs, use the original if you don't know much GML - however, if you know GML, use jujus script.
  • 0

Chris Matthews, Co-Leader of Digital X

#5 mme

mme

    MME

  • GMC Member
  • 1012 posts

Posted 14 January 2007 - 04:45 AM

You dont need a DLL to check if a drive exists, but a nice DLL

You can download an example were you dont need a dll:

http://www.mami.hoogetech.com/Gamemaker/gm_example.php - Link Broken

thank you MME, but please don't highjack my topic


Sorry just giving an alternative

Edited by mme, 05 November 2010 - 02:37 PM.

  • 0
gmc_mdu2.pngrsa_gmc_sig.png

#6 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 14 January 2007 - 03:34 PM

thank you MME, but please don't highjack my topic
  • 0

Chris Matthews, Co-Leader of Digital X

#7 Thull

Thull

    ACP Webdesigner

  • New Member
  • 340 posts

Posted 14 January 2007 - 04:43 PM

Great DLL! With the effort of mixing this dll with your other one, I can get the hard-drive drive, which is what i've needed for a long time!
  • 0

#8 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 14 January 2007 - 05:12 PM

thanks :(
  • 0

Chris Matthews, Co-Leader of Digital X

#9 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 15 January 2007 - 10:16 PM

@ everyone: this DLL may not be used in System Information Programs
  • 0

Chris Matthews, Co-Leader of Digital X

#10 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9603 posts
  • Version:GM:Studio

Posted 15 January 2007 - 10:23 PM

BTW, mme, yours doesn't work for me. It only recognized rives C and D on my computer (the two hard drives), but the CD/DVD drives weren't recognized. So this DLL would be necessary should someone need to get any non-hard drives ("soft drives"? :D )

Good work cdm!

-IMP ;) :)
  • 0

:GM123: Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea :)

:bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny: :excl: :bunny:


#11 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 15 January 2007 - 10:37 PM

thanks IMP

Edited by cdm319, 06 June 2008 - 01:15 PM.

  • 0

Chris Matthews, Co-Leader of Digital X

#12 muslim power

muslim power

    GMC Member

  • New Member
  • 540 posts

Posted 06 April 2007 - 08:45 PM

Nice
  • 0

#13 Arial

Arial

    GMC Member

  • Banned Users
  • 580 posts
  • Version:GM8

Posted 31 May 2008 - 08:18 PM

This DLL made by you that actualy can tell you which drive is CD/DVD or another drive. I tried it and it works. So can you alter it so that it can tell you from which drive you are Running the program. As I am working in mission protect I need a code that olny runs from cd.

Thanks a lot
Screw everyone who puts my quotes in his signature to make fun out of me.

#14 zedman1000

zedman1000

    GMC Member

  • New Member
  • 715 posts

Posted 03 June 2008 - 05:54 AM

To check the name of the drive your program is running on, use the following and then get the first letter of the string:

working_directory

and its temp folder with:

temp_directory

Edited by zedman1000, 03 June 2008 - 05:55 AM.

  • 0

#15 cbrad24

cbrad24

    GMC Member

  • New Member
  • 96 posts

Posted 03 June 2008 - 12:10 PM

To check the name of the drive your program is running on, use the following and then get the first letter of the string:

working_directory

and its temp folder with:

temp_directory

Or
//Returns drive (E.g. "C:\Documents and Settings\..." = "C:")
filename_drive(working_directory)
I'd say more but...

thank you MME, but please don't highjack my topic


  • 0

#16 acrog2

acrog2

    average user

  • GMC Member
  • 1118 posts

Posted 03 June 2008 - 11:37 PM

*
To check the name of the drive your program is running on, use the following and then get the first letter of the string:

working_directory

and its temp folder with:

temp_directory

Or
CODE
//Returns drive (E.g. "C:\Documents and Settings\..." = "C:")
filename_drive(working_directory)

or use %HOMEDRIVE%

Edited by acrog2, 03 June 2008 - 11:38 PM.

  • 0

#17 IsmAvatar

IsmAvatar

    Good Samaritan

  • GMC Member
  • 2411 posts
  • Version:GM8

Posted 04 June 2008 - 05:36 AM

If you wanted the individual drive letters from my dll, you could just write a script to split the string into each character.

Also, be aware, multiple calls to a dll requires a lot of overhead, compared to 1 call, which only requires the overhead once. It is almost definately faster to split the string in GML than to call the dll multiple times.

Still, not bad for your second dll. And I get honorable mention, so I'm happy :-p
  • 0
Posted Image LateralGM is an IDE for editing GM files on Linux, Mac, and Windows.
We also house the GM File Format Documentation and other projects of that nature.
IsmAvatar.com | Examples | Scripts | Particles | DLLs | Credit Me
Email | Registered

#18 death-droid

death-droid

    GMC Member

  • GMC Member
  • 2600 posts

Posted 04 June 2008 - 07:18 AM

Is there anyway to check the cd/dvd drive of a computer??
  • 0

Posted Image


#19 cdm319

cdm319

    C++ Programmer

  • New Member
  • 885 posts

Posted 06 June 2008 - 01:13 PM

Can we please not resurrect a topic from over a year ago?
Thanks.

By the way, Arial, zedman and cbrad 24 are right, those codes do what you want. I think ;)

Thanks zedman, cbrad24 and IsmAvatar.
  • 0

Chris Matthews, Co-Leader of Digital X

#20 Drara

Drara

    GMC Member

  • GMC Member
  • 325 posts

Posted 23 April 2010 - 02:06 PM

Well, I found this topic through the search.
At first I wanted to use that, but then I tested that this dll is completely senseless.

Exactly like that, you can check with

directory_exists("C:/")

any drive you want.
A running through all letters with this is a lot faster then calling the dll-functions, or?
  • 0

#21 alex21

alex21

    Destroy EvilCow BURP

  • New Member
  • 336 posts

Posted 25 April 2010 - 12:41 PM

It does not tell you which are virtual cd drives.
  • 0

Posted Image


#22 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 25 April 2010 - 12:48 PM

It does not tell you which are virtual cd drives.

No program should be able to tell.

Also, since it's my hobby, an abridged version of the program (FASM format ASM):
format PE GUI 4.0 DLL
entry start

include 'win32a.inc'
section 'dll' code data executable readable writeable
data import
library kernel32,'KERNEL32.DLL'
import kernel32,GetLogicalDrives,'GetLogicalDrives'
end data
align 16
start:
  cmp byte[f],0
  jnz .end
  inc byte[f]
  mov eax,[GetLogicalDrives]
  sub eax,DriveExists+5
  mov [DriveExists+1],eax
.end:
  xor eax,eax
  inc eax
  ret
align 16
DriveExists:
  call DriveExists
  fld qword[esp+4]
  fistp dword[esp-4]
  mov ecx,[esp-4]
  bt eax,ecx
  jc .yes
  fldz
  ret
.yes:
  fld1
  ret

f db 0
align 4
data export
export 'GETDRIVES.DLL',DriveExists,'DriveExists'
end data
align 4
data fixups
end data
One function, "DriveExists", cdecl, takes 1 argument which is the drive number (0 for A:, 1 for B:, 2 for C:, etc. Can also be achieved by calculating ord(string_upper(DriveLetter))-ord("A")), and returns true (real value, unlike the original which returned the string "true") if the drive exists and false if it doesn't.

Edited by score_under, 25 April 2010 - 01:08 PM.

  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#23 alex21

alex21

    Destroy EvilCow BURP

  • New Member
  • 336 posts

Posted 29 April 2010 - 09:36 PM

It does not tell you which are virtual cd drives.

No program should be able to tell.

Also, since it's my hobby, an abridged version of the program (FASM format ASM):
format PE GUI 4.0 DLL
entry start

include 'win32a.inc'
section 'dll' code data executable readable writeable
data import
library kernel32,'KERNEL32.DLL'
import kernel32,GetLogicalDrives,'GetLogicalDrives'
end data
align 16
start:
  cmp byte[f],0
  jnz .end
  inc byte[f]
  mov eax,[GetLogicalDrives]
  sub eax,DriveExists+5
  mov [DriveExists+1],eax
.end:
  xor eax,eax
  inc eax
  ret
align 16
DriveExists:
  call DriveExists
  fld qword[esp+4]
  fistp dword[esp-4]
  mov ecx,[esp-4]
  bt eax,ecx
  jc .yes
  fldz
  ret
.yes:
  fld1
  ret

f db 0
align 4
data export
export 'GETDRIVES.DLL',DriveExists,'DriveExists'
end data
align 4
data fixups
end data
One function, "DriveExists", cdecl, takes 1 argument which is the drive number (0 for A:, 1 for B:, 2 for C:, etc. Can also be achieved by calculating ord(string_upper(DriveLetter))-ord("A")), and returns true (real value, unlike the original which returned the string "true") if the drive exists and false if it doesn't.

Thanks for the info.

No program should be able to tell.

Actual I have virtual CD v9 And it does tell you which are vrtual CD drives even those made by other tools.
  • 0

Posted Image


#24 Kolink

Kolink

    Almighty Shinx

  • GMC Member
  • 2351 posts

Posted 14 September 2010 - 02:40 PM

Hmm, is anything wrong with the following GML to achieve the same thing?

// script getDrives()
// returns: ds_list of available drives
// CD/DVD drives are returned if there is a CD/DVD present
// Virtual drives are also returned if they are available

var i, drives, a, z;
drives = ds_list_create();
a = ord("A");
z = ord("Z");
for( i=a; i<=z; i+=1) {
   if( directory_exists(chr(i)+":")) ds_list_add(drives,chr(i));
}
return drives;

  • 0

Posted Image


#25 Drara

Drara

    GMC Member

  • GMC Member
  • 325 posts

Posted 16 September 2010 - 02:56 PM

It does not tell you which are virtual cd drives.

No program should be able to tell.

Also, since it's my hobby, an abridged version of the program (FASM format ASM):
format PE GUI 4.0 DLL
entry start

include 'win32a.inc'
section 'dll' code data executable readable writeable
data import
library kernel32,'KERNEL32.DLL'
import kernel32,GetLogicalDrives,'GetLogicalDrives'
end data
align 16
start:
  cmp byte[f],0
  jnz .end
  inc byte[f]
  mov eax,[GetLogicalDrives]
  sub eax,DriveExists+5
  mov [DriveExists+1],eax
.end:
  xor eax,eax
  inc eax
  ret
align 16
DriveExists:
  call DriveExists
  fld qword[esp+4]
  fistp dword[esp-4]
  mov ecx,[esp-4]
  bt eax,ecx
  jc .yes
  fldz
  ret
.yes:
  fld1
  ret

f db 0
align 4
data export
export 'GETDRIVES.DLL',DriveExists,'DriveExists'
end data
align 4
data fixups
end data
One function, "DriveExists", cdecl, takes 1 argument which is the drive number (0 for A:, 1 for B:, 2 for C:, etc. Can also be achieved by calculating ord(string_upper(DriveLetter))-ord("A")), and returns true (real value, unlike the original which returned the string "true") if the drive exists and false if it doesn't.


Sorry, but your dll is 100% useless, GM haves the function directory_exists which does in this case exactly the same...

Edited by Drara, 16 September 2010 - 02:56 PM.

  • 0