function MicroSDPresent: Boolean;
var
i : char;
FName: string;
Error: LongWord;
begin
Error := SetErrorMode(SEM_FAILCRITICALERRORS);
Result:= False;
for i := 'D' to 'Z' do
begin
if GetDriveType(PChar(i+':\')) = DRIVE_REMOVABLE then
Result:= CreateFile(PChar(Format('\\.\%s:\%s',[i,'prueba.txt'])),
GENERIC_READ, 0, nil, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0) <> INVALID_HANDLE_VALUE;
end;
SetErrorMode(Error);
end;
...
begin
if MicroSDPresent then
ShowMessage('MicroSD presente')
else
ShowMessage('MicroSD ausente');
end;