判断文件格式
判断文件格式,以便处理:
if UpperCase(ExtractFileExt(sFileName)) <> '.PDF' thenbeginimgCapture.Picture.Graphic := nil;imgCapture.Picture.LoadFromFile(sFileName);end;unit SysUtils;
function ExtractFileName(const FileName: string): string;//返回文件名
varI: Integer;
beginI := LastDelimiter(PathDelim + DriveDelim, FileName);Result := Copy(FileName, I + 1, MaxInt);
end;function ExtractFileExt(const FileName: string): string;//返回文件后缀名
varI: Integer;
beginI := LastDelimiter('.' + PathDelim + DriveDelim, FileName);if (I > 0) and (FileName[I] = '.') thenResult := Copy(FileName, I, MaxInt) elseResult := '';
end;
{-------------------------------------------------------------------------------过程名: isBmpFile参 数: AFileName:完整的文件名称功 能: 判断图片是不是合法的BMP格式返回值: TRUE:是bmp图片文件;FALSE 不