标签 - 德尔福

在Delphi中使用线程

在Delphi中使用线程很容易。 同步很好:-)   功能内容 uses System.Classes, System.SysUtils, Vcl.Forms; procedure Wait(Proc: TProc); var Thread: TThread; begin Thread := TThread.CreateAnonymousThread(procedure() begin Proc; end); Thread.FreeOnTerminate := True; Thread.Start; while not Thread.Finished do Application.ProcessMessages; end; 如何使用 Wait(procedure() begin // ....内容 end);

注册表监控(德尔福)

如何使用 procedure RegistryMonitor(RootKey: HKEY; Key: string; Proc: TProc; WatchSub: boolean); begin TThread.CreateAnonymousThread(procedure var Reg: TRegistry; Event: cardinal; begin Reg := TRegistry.Create; Reg.RootKey := RootKey; if Reg.OpenKeyReadOnly(Key) then begin Event := CreateEvent(nil, False, False, nil); if Event > 0 then begin while True do begin RegNotifyChangeKeyValue(Reg.CurrentKey, WatchSub, REG_NOTIFY_CHANGE_LAST_SET, Event, True); if WaitForSingleObject(Event, INFINITE) = WAIT_OBJECT_0 then TThread.Synchronize(TThread.CurrentThread, procedure begin Proc end); end; end; end; Reg.Free; end).Start; end; // PROC:命令 // WatchSub : 하위도...