标签: delphi-xe4

什么阻止将64位Windows平台添加到VCL组件包?

对于大多数Delphi和C++ Builder项目(包括组件包),您可以通过右键单击项目管理器中的"目标平台"项并选择"添加平台",然后在结果中选择"64位Windows"来添加64位Windows目标.对话.

最近在RAD Studio XE4的新安装中安装组件时,我无法对某些组件执行此操作.例如:

仅显示OSX和32位Windows的

这个具体的例子是TMS的高级多边形列表,但它也发生在其他组件包中 - 但不是全部.有些目标可用,对于那些我可以构建包并创建一个使用该组件的64位VCL表单应用程序.

什么阻止Win64目标出现在对话框中,我该如何重新启用它?

delphi target-platform delphi-xe4

3
推荐指数
1
解决办法
2665
查看次数

无法从字符串中删除"空字符"

几个月前我问了一个类似的问题.感谢Rob Kennedy,我可以把我的整个文本加载到Richedit 但是我无法删除Null chars.因为我用过,我可以加载我的文本Stream.


现在在这段代码中:

var
  strm : TMemorystream;
  str  : UTF8string;
  ss   : TStringstream;

begin
  strm := tmemorystream.Create;

  try
    strm.LoadFromFile('C:\Text.txt');
    setstring(str,PAnsichar(strm.Memory),strm.Size);
    str := StringReplace(str, #0, '', [rfReplaceAll]);  //This line doesn't work at all
    ss  := tstringstream.Create(str);
    Richedit1.Lines.LoadFromStream(ss);
  finally
    strm.Free;
    ss.Free;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

我转换TMemorystreamstring删除Null Chars,StringReplace()然后再将其转换TStringstream为加载它Richedit.lines.LoadFromStream.

但我的问题是我无法删除Null Character使用StringReplace().我可以替换其他角色但不能#0.

有没有办法直接删除null charcters TMemorystream并将其加载到Richedit …

delphi null character delphi-xe4

3
推荐指数
2
解决办法
3614
查看次数

E2010不兼容的类型:Delphi XE4中的"LPQUERY_SERVICE_CONFIGW"和"PQueryServiceConfigA"错误

我在Delphi 7中的代码中有以下代码:

 var
    objServiceConfig: PQueryServiceConfigA;
    ...
    ...
    objServiceConfig:= AllocMem(anySize);
    ...
    ...
    QueryServiceConfig(hSCService, objServiceConfig, anySize, anySize2)
    .....
    .....
Run Code Online (Sandbox Code Playgroud)

我收到错误: E2010 Incompatible types: 'LPQUERY_SERVICE_CONFIGW' and 'PQueryServiceConfigA'

在Delphi 7中一切正常但是将它迁移到Delphi XE4,我收到了这个错误.

当我改变上述声明objServiceConfig: PQueryServiceConfigA;objServiceConfig: LPQUERY_SERVICE_CONFIG;它的工作原理.是对还是我还要做什么?

更新:

在Delphi XE4 WinSvc中,QueryServiceConfig声明如下

function QueryServiceConfig(hService: SC_HANDLE;
  lpServiceConfig: LPQUERY_SERVICE_CONFIG; cbBufSize: DWORD;
  var pcbBytesNeeded: DWORD): BOOL; stdcall;  

{$EXTERNALSYM QueryServiceConfigA}

function QueryServiceConfigA(hService: SC_HANDLE;
  lpServiceConfig: LPQUERY_SERVICE_CONFIGA; cbBufSize: DWORD;
  var pcbBytesNeeded: DWORD): BOOL; stdcall;

{$EXTERNALSYM QueryServiceConfigW}

function QueryServiceConfigW(hService: SC_HANDLE;
  lpServiceConfig: LPQUERY_SERVICE_CONFIGW; cbBufSize: DWORD;
  var pcbBytesNeeded: DWORD): BOOL; stdcall; 
Run Code Online (Sandbox Code Playgroud)

在Delphi7,WinSvc中,QueryServiceConfig声明如下

function …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-7 delphi-xe4

3
推荐指数
1
解决办法
645
查看次数

正确地为静态数组中的记录分配/释放内存

昨天我发生了一些内存损坏,我非常怀疑一些记录数组是如何被分配和释放的.这是演示的简短版本:

type
  TMyRecord = record
    W: word;
    S: String;
  end;

  TMyRecordArray = array [1 .. 315] of TMyRecord;
  TArrayPointer = ^TMyRecordArray;

var
PageBase: TArrayPointer;

procedure TTestForm.FormCreate(Sender: TObject);
var
  iRecord: TMyRecord;
begin
  PageBase := AllocMem(SizeOf(TMyRecordArray));
  iRecord.W := 1;
  iRecord.S := 'TEST';
  PageBase^[1] := iRecord;
end;

procedure TTestForm.FormDestroy(Sender: TObject);
begin
  PageBase^[1] := Default (TMyRecord);
  FreeMem(TPageBase);
end;
Run Code Online (Sandbox Code Playgroud)

我很确定我做得不对,任何建议都会受到赞赏.

delphi delphi-xe4

3
推荐指数
1
解决办法
1405
查看次数

TClientDataSet遍历和删除记录导致某些记录在while循环中遍历两次(如果使用Index)

我有以下代码遍历所有数据TClientDataSet,我的目的是删除除以外的所有记录DocKey=20381.

但是使用以下代码,您将注意到DocKey = 20381被遍历两次的记录(遍历时间= 6,假设为5次,因为我们只有5条记录TClientDataSet).

如果我们启用此行 - > D.IndexFieldNames := 'DocKey',则数据将正确遍历.我可以知道这是一个Delphi漏洞吗?或者有什么办法解决这个除了使用IndexFieldNames

var
  D: TClientDataSet;
begin
  D := TClientDataSet.Create(Self);
  with D do begin
    FieldDefs.Add('DocKey', ftInteger);
    CreateDataSet;
    AppendRecord([20157]);
    AppendRecord([20162]);
    AppendRecord([20381]);
    AppendRecord([20372]);
    AppendRecord([20377]);
  end;
  // D.IndexFieldNames := 'DocKey';

  D.First;
  while not D.Eof do begin
    if D.Fields[0].AsInteger = 20381 then
      D.Next
    else
      D.Delete;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

delphi tclientdataset while-loop delete-row delphi-xe4

3
推荐指数
1
解决办法
2774
查看次数

“ HTTP / 1.1 301永久移动” EIdHTTPProtocolException

procedure TForm1.ExtractLinks(const URL: String; const StringList: TStringList);
{ Extract "href" attribute from A tags from an URL and add to a stringlist. }
var
  i: Integer;
  iDoc: IHTMLDocument2;
  iHTML: String;
  iv: Variant;
  iLinks: OleVariant;
  iDocURL: String;
  iURI: TidURI;
  iHref: String;
  iIdHTTP: TidHTTP;
  iListItem: TListItem;
begin
  StringList.Clear;
  ListView1.Clear;
  iURI := TidURI.Create(URL);
  try
    iDocURL := 'http://' + iURI.Host;
    if iURI.Path <> '/' then
      iDocURL := iDocURL + iURI.Path;
  finally
    iURI.Free;
  end;
  iDoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
  try
    iDoc.DesignMode := 'on';
    while iDoc.ReadyState …
Run Code Online (Sandbox Code Playgroud)

delphi delphi-xe4

3
推荐指数
1
解决办法
4559
查看次数

Delphi - 如何"重载"对象'类型的过程

'Delphi'提供任何方法来'重载''对象'类型的过程,如

TTesting = class(TObject)
Public
Type
TInformationEvent1 = procedure( x: integer ) of object; overload ;
TInformationEvent1 = procedure ( x: integer ; y: string) of object; overload ;
TInformationEvent1 = procedure ( x: integer ; y: string; z: Boolean) of object; overload ;
end
Run Code Online (Sandbox Code Playgroud)

我可以用这三种方式重载这个TInformationEvent1函数吗?

delphi overloading delphi-xe4

3
推荐指数
2
解决办法
831
查看次数

如何使用Delphi在窗口非客户区使用自定义光标

我有自定义Delphi VCL控件拦截WM_NCHITTEST消息并返回HTCAPTION以使控件在其父窗口上可移动.

该部分工作正常,但是当将HTCAPTION鼠标悬停在该控件上时,返回也会将我的自定义光标重置为Windows默认光标.有什么方法可以使用HTCAPTION,仍然显示我的自定义光标?

注意:我知道如何在不使用HTCAPTION和解决游标问题的情况下实现控制移动

delphi winapi cursor delphi-xe4

3
推荐指数
1
解决办法
330
查看次数

如何使用HeapCreate/HeapAlloc分配类?

如何在Delphi中使用HeapCreate和HeapAlloc分配类?以下示例将崩溃.

program Project2;

uses
  System.SysUtils,
  System.Classes,
  Winapi.Windows;

var
  SL: TStringList;
  Handle: THandle;
  P: ^TStringList;
begin
  Handle := HeapCreate(0, SizeOf(TStringList), SizeOf(TStringList));
  P := HeapAlloc(Handle, 0, SizeOf(TStringList));
  P.Add('some random string'); // crash

  HeapFree(Handle, 0, @P);
end.
Run Code Online (Sandbox Code Playgroud)

delphi delphi-xe4

3
推荐指数
1
解决办法
645
查看次数

Delphi:找不到字段'False'.只发生在我的电脑上

我有一个TCustomClientDataSet(在内存中)用于在Delphi程序中进行一些过滤.

我的过滤代码如下:

  CDSFilteredGroup.Filter := 'ACP_type = 1 AND ACP_by_default <> False';
  CDSFilteredGroup.Filtered := True;
Run Code Online (Sandbox Code Playgroud)

当我编译并运行它时,我只在我的计算机上安装了Delphi(XE4)时出现以下错误:

CDSFilteredGroup: Champ 'False' non trouvé.
Run Code Online (Sandbox Code Playgroud)

翻译:未找到Field'False'.相同的代码在我的同事计算机上编译和运行完全正常,但不是我的.我想念的某个地方必须有一个选项吗?

请记住,代码还可以正常工作......

delphi delphi-xe4

3
推荐指数
1
解决办法
449
查看次数