I tried to use DriveInfo.IsReady, but it returns false if an unformatted floppy is in the drive.
Jonas stuff worked:
bool MyDll::Class1::HasFloppy( wchar_t driveLetter ) {
wchar_t path[] = L"\\\\.\\A:";
path[ 4 ] = driveLetter;
SetLastError( 0 );
HANDLE drive = CreateFile( path, //__in LPCTSTR lpFileName,
GENERIC_READ, //__in DWORD dwDesiredAccess,
0, //__in DWORD dwShareMode,
0, //__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
OPEN_EXISTING, //__in DWORD dwCreationDisposition,
0, //__in DWORD dwFlagsAndAttributes,
0 //__in_opt HANDLE hTemplateFile
);
DWORD bytes_read;
char buf[ 512 ];
DWORD err( 0 );
if( !ReadFile( drive, buf, 512, &bytes_read, 0 ) )
err = GetLastError();
CloseHandle( drive );
return err != ERROR_NOT_READY;
}