是否可以打开文本文件并在另一个应用程序更新文件时读取内容,这样它不会导致锁定冲突?
我需要监视来自一个应用程序的日志文件,每次事件发生时由另一个应用程序更新.
我在尝试阅读之前检查文件是否正在使用,但这似乎并不适用于所有情况.
谢谢,彼得
我们目前使用WmiSet从网上联系到远程机器上运行的WMI查询和查询注册表设置.
问题是它只支持Delphi直到RAD Studio 2007.
我们目前正在升级到Delphi XE,需要知道是否有人知道 - 或者有 - 更新版本的WmiSet组件或类似的东西.
我们已尝试与供应商联系,但到目前为止,我们的任何查询都没有任何回复.
我正在尝试<Link role="self">使用XPath查询在以下XML文件中找到值.
<?xml version="1.0" encoding="utf-8"?>
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
<Copyright>Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
<BrandLogoUri>http://spatial.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
<StatusCode>201</StatusCode>
<StatusDescription>Created</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>ID|02.00.82.2300|</TraceId>
<ResourceSets>
<ResourceSet>
<EstimatedTotal>1</EstimatedTotal>
<Resources>
<DataflowJob>
<Id>ID</Id>
<Link role="self">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/ID</Link>
<Status>Pending</Status>
<CreatedDate>2011-03-30T08:03:09.3551157-07:00</CreatedDate>
<CompletedDate xsi:nil="true" />
<TotalEntityCount>0</TotalEntityCount>
<ProcessedEntityCount>0</ProcessedEntityCount>
<FailedEntityCount>0</FailedEntityCount>
</DataflowJob>
</Resources>
</ResourceSet>
</ResourceSets>
</Response>
Run Code Online (Sandbox Code Playgroud)
我在上一篇文章中看到了一个XPath查询,但我 …
我们需要比较两个(或更多)文本文件的内容,以确定是否需要创建备份.如果它们不同,我们会创建一个新备份.
我目前使用每个文件的CRC值来检查差异,但我想知道是否有更有效或更优雅的方法来检测文件之间的差异.
//Use madZIP to calculate the CRC fior this file
GetUncompressedFileInfo(Filename_1, Size_1, NewCRC);
//Use madZIP to calculate the CRC fior this file
GetUncompressedFileInfo(Filename_2, Size_2, OldCRC);
//if ThisFileHash = ExistingFileHash then
if (OldCRC <> NewCRC) then
CreateABackup;
Run Code Online (Sandbox Code Playgroud)
问候,彼得.
如何确定变量的值是否在"类型声明"的范围内.防爆.
Type
TManagerType = (mtBMGR, mtAMGR, mtHOOT);
...
var
ManagerType: TManagerType;
....
procedure DoSomething;
begin
if (ManagerType in TManagerType) then
DoSomething
else
DisplayErrorMessage;
end;
Run Code Online (Sandbox Code Playgroud)
谢谢,彼得.
我有一个应用程序启动一些线程来做东西.我有一个TThreadOnTerminate程序,每个线程访问一些线程变量,用结果填充网格.(每个线程执行不同的任务,但答案总是相同的,即成功或失败StringList的消息.)
所以我有:
procedure TFormMain.Thread1OnTerminate(Sender: TObject);
begin
Result := TThread1(Sender).Result;
AddMessagesToGrid(TThread1(Sender).Messages);
end;
procedure TFormMain.Thread2OnTerminate(Sender: TObject);
begin
Result := TThread2(Sender).Result;
AddMessagesToGrid(TThread2(Sender).Messages);
end;
Run Code Online (Sandbox Code Playgroud)
我的问题如下.我可以有一个'通用' OnTerminate程序来处理我所有线程的结果,如下所示?
procedure TFormMain.Thread1OnTerminate(Sender: TObject);
begin
Result := <Sender Thread>.Result;
AddMessagesToGrid(<Sender Thread>.Messages);
end;
Run Code Online (Sandbox Code Playgroud)
我们目前正在使用Delphi 2007.很快就升级(我希望)到Delphi XE.
是否有可能使应用程序系统的主要形式模态化?我的应用程序将从远程公司PC FTP文件.在此过程正在进行时,不应允许用户与桌面交互.
Application.MainFormOnTaskbar := True;
Application.ShowMainForm := False;
...
FormChild.ShowModal;
Run Code Online (Sandbox Code Playgroud) 我是XML的新手,我们需要使用新的Bing Spatial Data API进行GeoCoding .我已经设法以xml格式从他们那里得到了一个结果.我如何阅读响应中的特定元素,即.链接,状态和错误消息?
<?xml version="1.0" encoding="utf-8"?>
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
<Copyright>Copyright © 2011 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
<BrandLogoUri>http://spatial.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
<StatusCode>201</StatusCode>
<StatusDescription>Created</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>ID|02.00.82.2300|</TraceId>
<ResourceSets>
<ResourceSet>
<EstimatedTotal>1</EstimatedTotal>
<Resources>
<DataflowJob>
<Id>ID</Id>
<Link role="self">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/ID</Link>
<Status>Pending</Status>
<CreatedDate>2011-03-30T08:03:09.3551157-07:00</CreatedDate>
<CompletedDate xsi:nil="true" />
<TotalEntityCount>0</TotalEntityCount>
<ProcessedEntityCount>0</ProcessedEntityCount>
<FailedEntityCount>0</FailedEntityCount>
</DataflowJob>
</Resources>
</ResourceSet>
</ResourceSets>
</Response>
Run Code Online (Sandbox Code Playgroud)
我正在使用Delphi XE. …
有人知道如何在运行时向TFlowPanel添加控件(例如TImage)吗?
问候,彼得
我有一个具有 5 个不同大小框架的应用程序。当我从一个框架移动到另一个框架时,我想动态地重新调整主窗体的大小以适应框架。
我可以使用MinHeight/MinWidth框架的属性来强制主窗体适合框架,但是当移动到较小的框架时,主窗体不会调整它的大小。
有任何想法吗?
- 编辑
...
TFormMain = Class(TForm)
...
public
FrameImportPackage: TFrameImportPackage;
...
procedure TFormMain.MenuPackagesImportClick(Sender: TObject);
begin
if not (Assigned(FrameImportPackage)) then
begin
FrameImportPackage := TFrameImportPackage.Create(Self);
FrameImportPackage.LabelFrameCaption.Caption := 'Import or Edit a Package';
end
else
begin
FrameImportPackage.BringToFront;
end;
FrameImportPackage.Parent := Self;
end;
Run Code Online (Sandbox Code Playgroud)
- 编辑
问候, 彼得
delphi ×10
xml ×2
bing-api ×1
compare ×1
controls ×1
dynamic ×1
file ×1
file-io ×1
file-locking ×1
flowpanel ×1
frame ×1
geospatial ×1
kiosk ×1
modal-dialog ×1
resize ×1
typechecking ×1
types ×1
wmi ×1
wmi-query ×1
xpath ×1