2010. 9. 13. 02:51
ShellExecute()는 윈도우쉘 명령을 실행시킬 때 쓰는 함수이다.
내가 사용하는 용도는 두가지이다.
한가지는 탐색기를 열 때(지정한 폴더로 이동시키는 것 까지),
나머지 한가지는 파일(윈도우즈 확장자 연결 프로그램으로 등록된 확장자를 가진 파일)을 열 때 이다.
먼저 탐색기를 여는 방법이다.
ShellExecute(0, 'explore', PChar(descDir), nil, nil, SW_SHOWNORMAL);
다음으로 파일을 열 때 이다.
var
fileFullPath : String;
errCode : Cardinal;
begin
errCode := ShellExecute(handle, 'open', Pchar(fileFullPath) , nil, nil, SW_SHOW);
if errCode = 31 then ShowMessage('HWP가 설치되어 있지 않습니다'); //실행화일 없을때
if errCode = 2 then ShowMessage('파일이 존재하지 않습니다'); //파일 없을때
end;
'Windows Programming > Delphi 6/7' 카테고리의 다른 글
Delphi6/7 Virtual Key Codes (0) | 2010.09.13 |
---|---|
Delphi6/7 디렉토리(폴더) 다이알로그, 폴더속에 있는 파일들 복사하기 (0) | 2010.09.13 |
Delphi6/7 TADOQuery - Binary 조회 (0) | 2010.09.13 |
Delphi6/7 TADOQuery - 기본적인 조회 코드 조각 (0) | 2010.09.13 |
Delphi6/7 TDBGrid - Column autoFit Implementation (0) | 2010.09.13 |
2010. 9. 13. 02:33
델파이는 조회 결과레코드셋에 들어 있는 바이너리를
CreateBlobStream() 함수를 이용하여 받을 수 있다.
기본적으로 stream으로 받아서 메모리에 올린 후 원하는 작업을 하면 된다.
이 코드 조각에서는 바이너리를 파일로 저장하기 위해 TMemoryStream의 SaveToFile() 프로시져를 사용하였다.
var
code, tempFullPath: string;
stream : TStream;
blob : string;
mStream : TMemoryStream;
begin
with ADOQuery1 do begin
if Active then Close;
SQL.Clear;
SQL.Text := 'SELECT binary'
+ ' FROM tablename'
+ ' WHERE code=:code';
Parameters.ParamByName('code').Value := code;
// 여기서 Open의 결과는 한행만을 반환한다.
Open;
stream := CreateBlobStream(FieldByName('binary'), bmRead);
SetLength(blob, stream.Size);
stream.Read(Pointer(blob)^, stream.Size);
mStream := TMemoryStream.Create;
mStream.Write(Pointer(blob)^, Length(blob));
mStream.SaveToFile(tempFullPath);
end;
end;
'Windows Programming > Delphi 6/7' 카테고리의 다른 글
Delphi6/7 디렉토리(폴더) 다이알로그, 폴더속에 있는 파일들 복사하기 (0) | 2010.09.13 |
---|---|
Delphi6/7 ShellAPI unit의 ShellExecute (0) | 2010.09.13 |
Delphi6/7 TADOQuery - 기본적인 조회 코드 조각 (0) | 2010.09.13 |
Delphi6/7 TDBGrid - Column autoFit Implementation (0) | 2010.09.13 |
Delphi6/7 TDBGrid - Scroll problem (0) | 2010.09.13 |
2010. 9. 13. 02:25
보통 ADOQuery를 사용하여 많은 조회 쿼리를 수행한다.
아래는 ADOQuery를 사용할 때 쓰이는 기본적인 코드 조각이다.
with ADOQuery1 do begin
if Active then Close;
SQL.Clear;
SQL.Text := 'SELECT * FROM tablename';
+ ' WHERE name = :NAME;
Parameters.ParamByName('NAME').Value := 'ojh';
Open;
while not Eof do begin
// FieldByName('title').AsString;
// FieldByName('id').AsInteger;
Next;
end;
Close;
end;
end;
Close;
end;
'Windows Programming > Delphi 6/7' 카테고리의 다른 글
Delphi6/7 디렉토리(폴더) 다이알로그, 폴더속에 있는 파일들 복사하기 (0) | 2010.09.13 |
---|---|
Delphi6/7 ShellAPI unit의 ShellExecute (0) | 2010.09.13 |
Delphi6/7 TADOQuery - Binary 조회 (0) | 2010.09.13 |
Delphi6/7 TDBGrid - Column autoFit Implementation (0) | 2010.09.13 |
Delphi6/7 TDBGrid - Scroll problem (0) | 2010.09.13 |