Click here to Skip to main content
16,007,126 members
Home / Discussions / C#
   

C#

 
GeneralDirectX 9.0 Released Pin
Heath Stewart20-Dec-02 9:26
protectorHeath Stewart20-Dec-02 9:26 
QuestionDoes this type of Windows Tree Control exist??? Pin
LongRange.Shooter20-Dec-02 9:08
LongRange.Shooter20-Dec-02 9:08 
AnswerRe: Does this type of Windows Tree Control exist??? Pin
Kannan Kalyanaraman20-Dec-02 18:29
Kannan Kalyanaraman20-Dec-02 18:29 
GeneralRe: Does this type of Windows Tree Control exist??? Pin
LongRange.Shooter23-Dec-02 2:43
LongRange.Shooter23-Dec-02 2:43 
GeneralInsert a macro Pin
mvmeijer20-Dec-02 3:35
mvmeijer20-Dec-02 3:35 
GeneralLogical Drive Information Pin
matthias s.19-Dec-02 15:23
matthias s.19-Dec-02 15:23 
GeneralRe: Logical Drive Information Pin
Kannan Kalyanaraman19-Dec-02 18:02
Kannan Kalyanaraman19-Dec-02 18:02 
GeneralRe: Logical Drive Information Pin
Jeff J19-Dec-02 20:24
Jeff J19-Dec-02 20:24 
I've looked everywhere for functions like the ones you are interested in (and many others), but I suppose some Win32 calls were never ported to the CLR. I have found Environment.GetLogicalDrives(), which is similar to GetLogicalDriveStrings() in the Win32 API. Well, maybe someone else has found others, but I just use the PInvoke/DllImport stuff. Here's some code from one of my projects:

public class Volume {

[DllImport("kernel32.dll", EntryPoint="GetVolumeInformation", CharSet=CharSet.Auto)]
public extern static int
   GetVolumeInfo(string sRootPathName,
                 StringBuilder sbVolumeNameBuffer, 
                 int nVolumeNameSize,
                 out uint uVolumeSerialNumber,
                 out uint uMaximumComponentLength,
                 out uint uFileSystemFlags,
                 StringBuilder sbFileSystemNameBuffer,
                 int nFileSystemNameSize);

[DllImport("kernel32.dll", EntryPoint="GetDriveType", CharSet=CharSet.Auto)]
public extern static uint
   GetDriveType(string sRootPathName);

[DllImport("kernel32.dll", EntryPoint="GetDiskFreeSpaceEx", CharSet=CharSet.Auto)]
public extern static int
   GetDiskFreeSpaceEx(string sAnyPath,
                      out ulong ulFreeBytesAvailable, 
                      out ulong ulTotalNumberOfBytes, 
                      out ulong ulTotalNumberOfFreeBytes);
}

//... usage somewhere else ...

uint uSerialNum, uMaxEntryLen, uFileSysFlags;
StringBuilder sbLabelBuf = new StringBuilder(260);
StringBuilder sbFileSysTypeBuf = new StringBuilder(260);

int iSuccess =
   Volume.GetVolumeInfo("C:\\", sbLabelBuf, sbLabelBuf.Capacity,
                        out uSerialNum, out uMaxEntryLen, out uFileSysFlags,
                        sbFileSysTypeBuf, sbFileSysTypeBuf.Capacity);


FWIW, I'm amazed I have any hair left at all Smile | :)

Matthias Steinbart wrote:
In theory, there is no difference between theory and practice. In practice, however, there is.

Love that one.

Cheers
GeneralRe: Logical Drive Information Pin
Rein Hillmann19-Dec-02 21:31
Rein Hillmann19-Dec-02 21:31 
GeneralRe: Logical Drive Information Pin
leppie20-Dec-02 6:11
leppie20-Dec-02 6:11 
GeneralSecondary Thread Pin
kasturirawat19-Dec-02 14:25
kasturirawat19-Dec-02 14:25 
GeneralRe: Secondary Thread Pin
Eric Gunnerson (msft)20-Dec-02 8:19
Eric Gunnerson (msft)20-Dec-02 8:19 
Questionsecurity for a service? Pin
imran_rafique19-Dec-02 13:07
imran_rafique19-Dec-02 13:07 
GeneralCursor woes. Pin
Tom Welch19-Dec-02 4:06
Tom Welch19-Dec-02 4:06 
GeneralRe: Cursor woes. Pin
Rob Graham19-Dec-02 5:01
Rob Graham19-Dec-02 5:01 
GeneralRe: Cursor woes. Pin
Joel Matthias19-Dec-02 7:42
Joel Matthias19-Dec-02 7:42 
GeneralRe: Cursor woes. Pin
Tom Welch19-Dec-02 7:55
Tom Welch19-Dec-02 7:55 
GeneralRe: Cursor woes. Pin
Anonymous19-Dec-02 9:15
Anonymous19-Dec-02 9:15 
GeneralRe: Cursor woes. Pin
Joel Matthias19-Dec-02 9:14
Joel Matthias19-Dec-02 9:14 
GeneralArrayList Comparison/Diff Pin
gercules19-Dec-02 0:08
gercules19-Dec-02 0:08 
GeneralRe: ArrayList Comparison/Diff Pin
Rob Graham19-Dec-02 5:07
Rob Graham19-Dec-02 5:07 
GeneralRe: ArrayList Comparison/Diff Pin
Eric Gunnerson (msft)19-Dec-02 10:36
Eric Gunnerson (msft)19-Dec-02 10:36 
QuestionExtender Bug? Or am I missing something? Pin
FruitBatInShades18-Dec-02 23:53
FruitBatInShades18-Dec-02 23:53 
GeneralPoint out the error Pin
sns18-Dec-02 21:41
sns18-Dec-02 21:41 
GeneralRe: Point out the error Pin
Jeff J19-Dec-02 15:11
Jeff J19-Dec-02 15:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.