Jump to content


Photo

Detect when a usb drive is inserted and drive type


  • This topic is locked This topic is locked
3 replies to this topic

#1 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 19 July 2011 - 03:23 PM

LogicalDrives.dll DETECT WHEN A USB IS DETECTED and the type of a drive
by SenJe0 and SyncViews

Hi,
Im proud to announce my first ever dll :rolleyes: . Actually someone helped me, and did most of the work :P but I'm still proud to be part of it.

We made this after I searched the forums and found no dll like this and no one ofered to help apart from SyncViews. The most helpful person I've found in this community. Plus some annoying people kept reminding me about the fact that I knew C :P. That was a joke....

Anyway, enough of the ranting. This was developed in C++

No source is included

It's heavily commented

It includes a .gmk example and a dll. Basically it has two functions it calls from the LogicalDrives.dll and these are stored in two global variables:


global.get_logical_drives gives a list of drives present. Actually this can be used to detect a new drive by comparing current drives and comparing it to the number of drives when a new drive is inserted. I don't want to go into the binary bit explanation of this, but the long and short is that it returns the drive letter of a usb inserted.

global.get_drive_type will give you the type of drive inserted. It returns one of the following results.

0 = The drive type cannot be determined.
1=The root path is invalid; for example, there is no volume mounted at the specified path.
2=The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader.
3=The drive has fixed media; for example, a hard drive or flash drive.
4=The drive is a remote (network) drive.
5=The drive is a CD-ROM drive.
6=The drive is a RAM disk.




Credit is not compulsory but is appreciated. Comments are welcome.
Download link

Please DONT host mirrors and I LOVE SYNCVIEWS

Edit: To use the get_drive type function add script "scr_drive"
He'res the code:

global.get_drive_type=external_define("LogicalDrives.dll", "get_drive_type",     dll_cdecl, ty_real, 1, ty_string);
return external_call(global.get_drive_type,argument0);

Now to use the code to detect the drive type scr_drive("E:\) or replace E with whatever drive you want... the value is returned so you can store it in a variable... :thumbsup:

Edited by SenJe0, 20 August 2011 - 11:28 PM.

  • 0

#2 SenJe0

SenJe0

    GMC Member

  • GMC Member
  • 733 posts

Posted 03 August 2011 - 09:41 PM

Edit: This is actually useful....sync is very good...

Edited by SenJe0, 12 September 2011 - 09:33 PM.

  • 0

#3 3141592526

3141592526

    GMC Member

  • GMC Member
  • 214 posts

Posted 16 October 2011 - 09:00 PM

link is down.
can anyone post a new one?
  • 0

#4 SyncViews

SyncViews

    GMC Member

  • GMC Member
  • 392 posts

Posted 18 October 2011 - 08:09 PM

http://gmc.yoyogames...howtopic=522261
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users