Programming & Tools/Delphi
[Delphi] sysutils.pas 의 유용한 함수
다크쌍피
2010. 3. 17. 17:59
function ChangeFileExt(const FileName, Extension: string): string;
// 바뀐 문자열만 리턴
// aaa.txt 를 aaa.avi 로 바꿀 경우
// ShowMessage( ChangeFileExt('aaa.txt', '.avi') );
// aaa.avi 로 출력
function FileSize(var F): Integer;
// 파일 크기
function FileAge(const FileName: string): Integer;
// 파일을 생성한 날짜
function FileDateToDateTime(FileDate: Integer): TDateTime;
// 날짜 := FileDateToDateTime( FileAge('FileName') );
function FileSetDate(Handle: Integer; Age: Integer): Integer; overload;
// 파일을 생성 날짜 변경
function DateTimeToFileDate(DateTime: TDateTime): Integer;
// TDateTime형을 Integer형으로 리턴
function FileSetAttr(const FileName: string; Attr: Integer): Integer;
// 파일의 속성 변경(읽기전용,숨김등..)
function FileSetReadOnly(const FileName: string; ReadOnly: Boolean): Boolean;
// True=읽기전용, False=해제
function DiskSize(Drive: Byte): Int64;
// 드라이브(디스크) 용량
function DiskFree(Drive: Byte): Int64;
// 드라이브 남은 용량
// (Drive: 0=Default Drive, 1=A:, 2=B:, 3=C:, 4=D: 등)
function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
function AnsiDequotedStr(const S: string; AQuote: Char): string;
// ShowMessage( AnsiDequotedStr('-ABCDEF-GHIJK$..', '-') );
// Result -> ABCDEF
function AnsiLastChar(const S: string): PChar;
// 문자열의 마지막 문자 리턴 (2Byte 문자도 가능)
procedure AppendStr(var Dest: string; const S: string); deprecated;
// Dest := Dest + S;
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
// Boolean 값 비교, UseBoolStrs 을 True로 할 경우 문자열로 리턴
function ByteToCharIndex(const S: string; Index: Integer): Integer;
// S 문자열 길이를 리턴. S 문자열 길이보다 Index 값이 크면 0을 리턴한다. (그외 Index 값 리턴)
function ByteToCharLen(const S: string; MaxLen: Integer): Integer;
// S 문자열 길이보다 MaxLen 값이 크면, S 길이를 리턴한다. (그 외 MaxLen 값 리턴)
function ByteType(const S: string; Index: Integer): TMbcsByteType;
// S[Index] 값이 1바이트 값인지, 2바이트(한글) 값의 첫번째 바이트인지, 두번째 바이트인지 판별한다.
ex)
var
ty: TMbcsByteType;
begin
ty := ByteType('ABC하하012',5);
case ty of
mbSingleByte: ShowMessage('1byte 문자');
mbLeadByte : ShowMessage('2byte 문자의 첫번째 바이트');
mbTrailByte : ShowMessage('2byte 문자의 두번째 바이트')
end;
end;
[출처 : 델마당 - 강좌,팁,정보]
// 바뀐 문자열만 리턴
// aaa.txt 를 aaa.avi 로 바꿀 경우
// ShowMessage( ChangeFileExt('aaa.txt', '.avi') );
// aaa.avi 로 출력
function FileSize(var F): Integer;
// 파일 크기
function FileAge(const FileName: string): Integer;
// 파일을 생성한 날짜
function FileDateToDateTime(FileDate: Integer): TDateTime;
// 날짜 := FileDateToDateTime( FileAge('FileName') );
function FileSetDate(Handle: Integer; Age: Integer): Integer; overload;
// 파일을 생성 날짜 변경
function DateTimeToFileDate(DateTime: TDateTime): Integer;
// TDateTime형을 Integer형으로 리턴
function FileSetAttr(const FileName: string; Attr: Integer): Integer;
// 파일의 속성 변경(읽기전용,숨김등..)
function FileSetReadOnly(const FileName: string; ReadOnly: Boolean): Boolean;
// True=읽기전용, False=해제
function DiskSize(Drive: Byte): Int64;
// 드라이브(디스크) 용량
function DiskFree(Drive: Byte): Int64;
// 드라이브 남은 용량
// (Drive: 0=Default Drive, 1=A:, 2=B:, 3=C:, 4=D: 등)
function AnsiExtractQuotedStr(var Src: PChar; Quote: Char): string;
function AnsiDequotedStr(const S: string; AQuote: Char): string;
// ShowMessage( AnsiDequotedStr('-ABCDEF-GHIJK$..', '-') );
// Result -> ABCDEF
function AnsiLastChar(const S: string): PChar;
// 문자열의 마지막 문자 리턴 (2Byte 문자도 가능)
procedure AppendStr(var Dest: string; const S: string); deprecated;
// Dest := Dest + S;
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
// Boolean 값 비교, UseBoolStrs 을 True로 할 경우 문자열로 리턴
function ByteToCharIndex(const S: string; Index: Integer): Integer;
// S 문자열 길이를 리턴. S 문자열 길이보다 Index 값이 크면 0을 리턴한다. (그외 Index 값 리턴)
function ByteToCharLen(const S: string; MaxLen: Integer): Integer;
// S 문자열 길이보다 MaxLen 값이 크면, S 길이를 리턴한다. (그 외 MaxLen 값 리턴)
function ByteType(const S: string; Index: Integer): TMbcsByteType;
// S[Index] 값이 1바이트 값인지, 2바이트(한글) 값의 첫번째 바이트인지, 두번째 바이트인지 판별한다.
ex)
var
ty: TMbcsByteType;
begin
ty := ByteType('ABC하하012',5);
case ty of
mbSingleByte: ShowMessage('1byte 문자');
mbLeadByte : ShowMessage('2byte 문자의 첫번째 바이트');
mbTrailByte : ShowMessage('2byte 문자의 두번째 바이트')
end;
end;
[출처 : 델마당 - 강좌,팁,정보]