type TForm1 = class(TForm) btnHide: TButton; edtProcessName: TEdit; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure btnHideClick(Sender: TObject); private { Private declarations } public { Public declarations }
m_hCommDevice:THandle; m_hCommEvent:THandle; end;
var Form1: TForm1;
implementation
uses Unit2, untConst;
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var dwReturn:DWORD ; begin if(m_hCommDevice <> 0) then begin if(m_hCommEvent <> 0) then begin DeviceIoControl(m_hCommDevice, IO_DEREFERENCE_EVENT, nil, 0, nil, 0, dwReturn, nil); CloseHandle(m_hCommEvent); end; CloseHandle(m_hCommDevice); end; end;