[Delphi] Window Taskbar Control

 
// AutoHide -> Show always
var
 ABData: TAppBarData;
begin
 ABData.cbSize := SizeOf(TAppBarData);
 ABData.hWnd := FindWindow('SHELL_TRAYWND', nil);
 ABData.lParam := LParam(0);
 SHAppBarMessage($0000000a, ABData);
// Visible False
var
 hTaskbar: THandle;
begin
 hTaskbar := FindWindow('Shell_TrayWnd', Nil);
 ShowWindow(hTaskbar, SW_HIDE);
//Show Taskbar
var
 hTaskbar: THandle;
begin
 hTaskbar := FindWindow('Shell_TrayWnd', Nil);
 ShowWindow(hTaskbar, SW_SHOWNORMAL);

[Delphi] Get MD5 Checksum


var
 IdMD5: TIdHashMessageDigest5;
 FS: TFileStream;
begin
IdMD5 := TIdHashMessageDigest5.Create;
FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
Result := IdMD5.HashStreamAsHex(FS);
finally
FS.Free;
IdMD5.Free;
end;
end;

[Delphi] Get path with Drag and Drop


//OnCreate

DragAcceptFiles(Handle, True);

//Procedure
procedure TForm2.WMDROPFILES(var Msg: TWMDropFiles);
var
 i, amount: Integer;
 FileName: array[0..MAX_PATH] of Char;
begin
 inherited;
 try
 Amount := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, MAX_PATH);
 for i := 0 to (Amount - 1) do
 begin
 DragQueryFile(Msg.Drop, i, FileName, MAX_PATH);
 //FileName에 파일/폴더 path가 들어옵니다. 
 finally
 DragFinish(Msg.Drop);
 end;
end;

 

[Delphi] Html to String


var
IdHTTP: TIdHTTP;
Stream: TStringStream;
begin
IdHTTP := TIdHTTP.Create(nil);
Stream := TStringStream.Create;
try
try
IdHTTP.Get('URL', Stream);
JenkinsParsingResult := Stream.DataString;
except
//exception Raise... (URL is not valid)
end;
finally
tmr1.Enabled := True;
Stream.Free;
IdHTTP.Free;
end;
end;

[Delphi] Proccess is running?


var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
Result := False;
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
begin
Result := True;
end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;