Delphi
2022-12-27
73
use ActiveX, ComObj;const wdFindContinue = 1; wdReplaceOne = 1; wdReplaceAll = 2;var WordApp: Variant;begin // create OLE object for MS Word application: WordApp := CreateOLEObject('Word.Application'); // load a document from your file
2022-12-27
32
uses Windows;...procedure SetNumLockOn;var KeyState: TKeyBoardState;begin GetKeyboardState(KeyState); if GetKeyState(VK_NUMLOCK) = 0 then begin KeyState[VK_NUMLOCK] := 1; SetKeyboardState(KeyState); end;end;
2022-12-27
40
TRichEdit:var pt: TPoint;begin with richedit1 do begin Perform(messages.EM_POSFROMCHAR, WPARAM(@pt), selstart); label1.caption := Format('(%d, %d)', [pt.x, pt.y]); end;end;TMemo and TEditvar r: LongInt;begin with memo1 do begin r
2022-12-27
87
将完整文件加载到TStringList实例中。然后遍历列表中的项目,并使用Pos函数检查该行是否以“ PIL”开头(如果您将其添加到列表框中)。当需要保存可能已更改的文件的时间回来时,您将再次遍历列表框中的项目,但是这次您要从上到下进行操作。对于以“ PIL”开头的每一行,请使用 Listbox.Items.IndexOf方法查看它是否在列表框中,如果没有,请从字符串列表中将其删除。然后,将字符串列表写回到文件中。例:在表单专用部分中,您声明一个字段:FFilelines.Loadfromfile(fi
2022-12-27
34
function IsDFMBinary(FileName: string): Boolean;var F: TFileStream; B: Byte;begin B := 0; F := TFileStream.Create(FileName, fmOpenRead); try F.Read( B, 1 ); Result := B = $FF; finally F.Free; end;end;
2022-12-27
31
function IntToRoman(num: Cardinal): string;const Nvals = 13; vals: array [1..Nvals] of word = (1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000); roms: array [1..Nvals] of string[2] = ('I', 'IV', 'V', 'IX',
2022-12-27
64
如果安装了给定程序ID的程序并在系统中注册,则以下代码将返回True;否则,则返回False。uses System.Win.ComObj,ActiveX; { Access.ApplicationExcel.ApplicationFrontPage.ApplicationOutlook.ApplicationPowerPoint.ApplicationMSProject.ApplicationWord.Application//delphitop.com}function ProgIDInstall
2022-12-27
60
Windows检测到诸如键盘或鼠标输入之类的活动�C长时间闲置后,系统可能会进入睡眠模式和/或关闭显示设备的电源。这是您可以用来防止系统在关键操作期间进入休眠状态的单元。unit SystemCriticalU;interfaceuses Windows;type TSystemCritical = class private FIsCritical: Boolean; procedure SetIsCritical(const Value: Boolean) ; protected