This is the archived version of Roland Weigelt's weblog that ran from 2003 to 2023 at weblogs.asp.net

Strange: GetProcessesByName and Floppy Drive Access

Here's something strange: Each time I call the method Process.GetProcessesByName my floppy drive is accessed, which is rather annoying especially if no disk is inserted.

If you want to try it yourself, here's the code for a minimal command line app:

using System;
using System.Diagnostics;
class GetProcessesByNameDemo
{
static void Main(string[] args)
{
Process[] arrProcesses=Process.GetProcessesByName("notepad");
}
}

A search on Google Groups for "getprocessesbyname floppy" shows (at least at the moment of writing these lines) that I'm not the only one with this problem; unfortunately I could find neither an explanation nor a solution.

So.... anybody out there knowing more about this strange behavior?

3 Comments

  • Is your A: drive in your ENV PATH value?

  • Hi Adam,



    no, it's not.

  • Hi Roland,



    If you want to have fun with that try this: add a Console.ReadLine() just before and just after the GetProcessByName(). The start the EXE - it will stop and wait for a newline to enter. Attach the debugger in native (!) mode only and press RETURN. You'll notice that quite a lot (guess 50+) DLLs are now loaded. Just for the GetProcessByName()? It looks as if the process connects to the performance counter API which in fact will also include counters for all disks. This may (?) be the reason since some counter providers may need to check what resources (in this case disks) are available.



    Jochen

Comments have been disabled for this content.