uses
  ShellApi;

function CopyDir(const fromDir, toDir: string): Boolean;
var
  fos: TSHFileOpStruct;
begin
  ZeroMemory(@fos, SizeOf(fos));
  with fos do
  begin
    wFunc  := FO_COPY;
    fFlags := FOF_FILESONLY;
    pFrom  := PChar(fromDir + #0);
    pTo    := PChar(toDir)
  end;
  Result := (0 = ShFileOperation(fos));
end;


function MoveDir(const fromDir, toDir: string): Boolean;
var
  fos: TSHFileOpStruct;
begin
  ZeroMemory(@fos, SizeOf(fos));
  with fos do
  begin
    wFunc  := FO_MOVE;
    fFlags := FOF_FILESONLY;
    pFrom  := PChar(fromDir + #0);
    pTo    := PChar(toDir)
  end;
  Result := (0 = ShFileOperation(fos));
end;

function DelDir(dir: string): Boolean;
var
  fos: TSHFileOpStruct;
begin
  ZeroMemory(@fos, SizeOf(fos));
  with fos do
  begin
    wFunc  := FO_DELETE;
    fFlags := FOF_SILENT or FOF_NOCONFIRMATION;
    pFrom  := PChar(dir + #0);
  end;
  Result := (0 = ShFileOperation(fos));
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  if cCopyDir('d:\download', 'e:\') = True then
    ShowMessage('Directory copied.');
end;


'APP > 파일관련' 카테고리의 다른 글

SelectDirectory 확장  (0) 2012.10.23
SelectDirectory 원하는 위치에 띄우기  (0) 2012.10.23
파일 버전 구하기  (0) 2012.10.23
부모풀더까지 한방에 만들기  (0) 2012.10.23
Posted by ezmind
:
 
// '%d.%d.%d.%d' => '4.13.128.0'
// '%.2d-%.2d-%.2d' => '04-13-128'
function GetFileVersion(const FileName: String;
  const Fmt: String = '%d.%d.%d.%d'): String;
var
  iBufferSize: DWORD;
  iDummy: DWORD;
  pBuffer: Pointer;
  pFileInfo: Pointer;
  iVer: Array[1..4] of Word;
begin
  // set default value
  Result := '';
  // get size of version info (0 if no version info exists)
  iBufferSize := GetFileVersionInfoSize(PChar(FileName), iDummy);
  if (iBufferSize > 0) then
  begin
    GetMem(pBuffer, iBufferSize);
    try
    // get fixed file info
    GetFileVersionInfo(PChar(FileName), 0, iBufferSize, pBuffer);
    VerQueryValue(pBuffer, '\', pFileInfo, iDummy);
    // read version blocks
    iVer[1] := HiWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionMS);
    iVer[2] := LoWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionMS);
    iVer[3] := HiWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionLS);
    iVer[4] := LoWord(PVSFixedFileInfo(pFileInfo)^.dwFileVersionLS);
    finally
      FreeMem(pBuffer);
    end;
    // format result string
    Result := Format(Fmt, [iVer[1], iVer[2], iVer[3], iVer[4]]);
  end;
end;


'APP > 파일관련' 카테고리의 다른 글

SelectDirectory 확장  (0) 2012.10.23
SelectDirectory 원하는 위치에 띄우기  (0) 2012.10.23
폴더 복사,이동,삭제  (0) 2012.10.23
부모풀더까지 한방에 만들기  (0) 2012.10.23
Posted by ezmind
:

TEXT 파일 제어

APP 2012. 10. 23. 20:03 |
 
procedure TForm1.Button1Click(Sender: TObject);
var
  f1 : textfile;
begin
  assignfile(f1, 'Test.txt');
  if FileExists( 'Test.txt' ) then
    Append(f1)  // 파일 있으면 내용추가
  else
    Rewrite(f1); // 없으면 만들기
  Writeln(f1,'쓸내용1');
  closefile(f1);

end;


'APP' 카테고리의 다른 글

GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
파일명으로 아이콘 구하기  (0) 2012.10.23
클립보드  (0) 2012.10.23
프린트 스크린 키 눌렸는지 확인  (0) 2012.10.23
Posted by ezmind
:
 

if ForceDirectories('C:\myFolder\sub1\sub2') then Caption := 'C:\myFolder\sub1\sub2 생성 완료';

'APP > 파일관련' 카테고리의 다른 글

SelectDirectory 확장  (0) 2012.10.23
SelectDirectory 원하는 위치에 띄우기  (0) 2012.10.23
폴더 복사,이동,삭제  (0) 2012.10.23
파일 버전 구하기  (0) 2012.10.23
Posted by ezmind
:

클립보드

APP 2012. 10. 23. 19:56 |
 
클립보드에 있는 이미지 찍기 

uses clipbrd; procedure drawFromClip; begin with ClipBoard do begin if HasFormat(CF_BITMAP) then begin Image1.Picture.Bitmap.Assign(ClipBoard) end else if HasFormat(CF_PICTURE) then Image1.Picture.Assign(ClipBoard) else if HasFormat(CF_METAFILEPICT) then Image1.Picture.Metafile.Assign(ClipBoard); end; end;

 
클립보드에 넣기, 꺼내기


unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, clipbrd; type TForm1 = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } procedure WMDrawClipboard(var Msg: TMessage) ; message WM_DRAWCLIPBOARD; procedure WMChangeCBChain(var Msg: TMessage) ; message WM_CHANGECBCHAIN; public { Public declarations } end; var Form1: TForm1; NextInChain : THandle; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin NextInChain := SetClipboardViewer(Handle) ; end; procedure TForm1.FormDestroy(Sender: TObject); begin ChangeClipboardChain(Handle, NextInChain) ; end; // 클립보드 내용이 바뀌면 발생하는 메세지 procedure TForm1.WMDrawClipboard(var Msg:TMessage) ; begin if Clipboard.HasFormat(cf_text) then begin Memo1.Lines.Clear; Memo1.PasteFromClipboard; end else begin //do something with other clipboard formats end; //pass the message on to the next window if NextInChain <> 0 then SendMessage(NextInChain, WM_DrawClipboard, 0, 0) end; // 다른 클립보드 뷰어가 바뀐상황을 체크하고 다음 체인에게도 알려준다 procedure TForm1.WMChangeCBChain(var Msg: TMessage) ; var Remove, Next: THandle; begin Remove := Msg.WParam; Next := Msg.LParam; with Msg do if NextInChain = Remove then NextInChain := Next else if NextInChain <> 0 then SendMessage(NextInChain, WM_ChangeCBChain, Remove, Next) end; end.





클립보드 내용 바뀐거 체크


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, clipbrd;

type

  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    procedure WMDrawClipboard(var Msg: TMessage) ; message WM_DRAWCLIPBOARD;
    procedure WMChangeCBChain(var Msg: TMessage) ; message WM_CHANGECBCHAIN;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  NextInChain : THandle;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  NextInChain := SetClipboardViewer(Handle) ;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  ChangeClipboardChain(Handle, NextInChain) ;
end;

// 클립보드 내용이 바뀌면 발생하는 메세지
procedure TForm1.WMDrawClipboard(var Msg:TMessage) ;
begin
 if Clipboard.HasFormat(cf_text) then
 begin
  Memo1.Lines.Clear;
  Memo1.PasteFromClipboard;
 end
 else
 begin
  //do something with other clipboard formats
 end;
 //pass the message on to the next window
 if NextInChain <> 0 then
  SendMessage(NextInChain, WM_DrawClipboard, 0, 0)
end;

// 다른 클립보드 뷰어가 바뀐상황을 체크하고 다음 체인에게도 알려준다
procedure TForm1.WMChangeCBChain(var Msg: TMessage) ;
var
  Remove, Next: THandle;
begin
  Remove := Msg.WParam;
  Next := Msg.LParam;
 with Msg do
  if NextInChain = Remove then
   NextInChain := Next
  else if NextInChain <> 0 then
   SendMessage(NextInChain, WM_ChangeCBChain, Remove, Next)
end;

end.



'APP' 카테고리의 다른 글

GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
파일명으로 아이콘 구하기  (0) 2012.10.23
TEXT 파일 제어  (0) 2012.10.23
프린트 스크린 키 눌렸는지 확인  (0) 2012.10.23
Posted by ezmind
:
 
if GetAsyncKeyState(VK_SNAPSHOT)<>0 then
begin
  showmessage('눌렀음');
end;

 

'APP' 카테고리의 다른 글

GUID 생성  (0) 2012.10.23
현재 떠있는 모든 창 캡션 구하기  (0) 2012.10.23
파일명으로 아이콘 구하기  (0) 2012.10.23
TEXT 파일 제어  (0) 2012.10.23
클립보드  (0) 2012.10.23
Posted by ezmind
: