473,387 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to get the harddrive drive letter? (or how many drive in a computer)

how can i know how many drive in computer?

Thanks in advance
Nov 16 '05 #1
2 6343
you may use the Windows API method below:DWORD GetLogicalDriveStrings(
DWORD nBufferLength,
LPTSTR lpBuffer
);
"Jason Chan" <no@mail.com> дÈëÏûÏ¢ÐÂÎÅ
:eg*************@TK2MSFTNGP10.phx.gbl...
how can i know how many drive in computer?

Thanks in advance

Nov 16 '05 #2
You can use WMI

Here is an example:

/* CODE BEGIN */
using System;
using System.Management;

public class network
{
public static void Main()
{
SelectQuery query = new SelectQuery( "select name, FreeSpace from
win32_logicaldisk where drivetype=3" );
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

foreach( ManagementObject mo in searcher.Get() )
{
Console.WriteLine( "Drive letter is: {0}", mo["name"] );
Console.WriteLine( "Drive's free space is: {0}", mo["FreeSpace"] );
}

// Here to stop app from closing
Console.WriteLine( "\n\nPress Return to exit." );
Console.Read();
}
}
/* CODE END */
I have an example app here for network drives.
http://www.publicjoe.f9.co.uk/csharp/snip/snip010.html
The page has links to relevant MSDN pages as well.

Hope this helps

Publicjoe
C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Snippets at http://www.publicjoe.f9.co.uk/csharp/snip/snippets.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html


"Jason Chan" <no@mail.com> wrote in message
news:eg*************@TK2MSFTNGP10.phx.gbl...
how can i know how many drive in computer?

Thanks in advance

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
0
by: BK Drake | last post by:
I am trying to assign a drive letter to a hidden partition. I have a hard drive that has 2 paritions - a system and a data partition. When I retore with an image the system drive the data drive...
0
by: john doe | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
7
by: jimdscudder | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
4
by: sanjana | last post by:
hi i m using the win32_diskdrive class for detecting a memory card insertion and removal..and this class detects memory card(sd card..etc) insertion removal from the device the deviceid...
4
by: Jim Carlock | last post by:
function CreateMyDataBaseFile($FQFN, $UID, $PW) { $db = "sqlite:" . $FQFN; $sql = "CREATE TABLE Customers(name1 TEXT, name2 TEXT);"; $dbh = new PDO($db, $UID, $PW); $dbh->exec($sql); $dbh =...
5
by: BigM | last post by:
Hi Guys, I am working up a little 'documents' section to an app of mine, where people can add links to docs on various share drives in our LAN, and they are displayed along with other details and...
4
by: heiro | last post by:
I want to make a vb6 project that could disconnect the pen drive from my computer and i could change the drive letter its using (i.e , from F:\ to Z:\)? Do you have sample codes that could do this...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.