小编Bra*_*nko的帖子

如何处理从我的GUI应用程序启动的控制台窗口?

在我的GUI应用程序中,我运行控制台应用程序并需要其窗口的句柄.我尝试使用EnumWindows(),请参阅下面的代码,但它不起作用.在列表中没有我的控制台应用程序.

type
  TEnumWindowsData = record
    ProcessId: Cardinal;
    WinHandle: THandle;
    List: TStrings;                 // For test only
  end;
  PEnumWindowsData = ^TEnumWindowsData;

function FindWindow(hWnd: THandle; lParam: LPARAM): BOOL; stdcall;
var
  ParamData: TEnumWindowsData;
  ProcessId: Cardinal;
  WinTitle: array[0..200] of Char;  // For test only
begin
  ParamData := PEnumWindowsData(lParam)^;
  GetWindowThreadProcessId(hWnd, ProcessId);
  if ProcessId <> ParamData.ProcessId then
    Result := True
  else begin
    ParamData.WinHandle := hWnd;
    Result := False;
  end;
  // For test only
  GetWindowText(hWnd, WinTitle, Length(WinTitle) - 1);
  ParamData.List.Add(IntToStr(ProcessId) + ' ' + IntToStr(hWnd) + ' ' …
Run Code Online (Sandbox Code Playgroud)

delphi winapi windows-7 delphi-xe2

12
推荐指数
2
解决办法
6379
查看次数

如何从图标中提取特定大小的图像?

如何从具有多个图像的图标中提取特定尺寸的图像或所有图像?

delphi delphi-2010

8
推荐指数
1
解决办法
3200
查看次数

Delphi XE3 - TDataSet的性能问题

使用XE3程序进行数据处理的时间比使用XE2编译的相同程序多10倍.这是已知问题(可能主要指TStringField),向QC 111942报告,但尚未修复.有没有人针对这个问题进行修复/解决?

TIA Branko

delphi delphi-xe3

6
推荐指数
1
解决办法
450
查看次数

是否有可能获得类属性的索引?

type
  TMyClass = class
  ...
  public
    ...
    property P1: Integer Index 1 read GetInteger write SetInteger;
    property P2: Integer Index 2 read GetInteger write SetInteger;
    property P3: Integer Index 3 read GetInteger write SetInteger;
    ...
  end;
Run Code Online (Sandbox Code Playgroud)

是否有可能获得类属性的索引?例如,像

  I := IndexOfProperty(TMyClass.P2);
Run Code Online (Sandbox Code Playgroud)

delphi properties

6
推荐指数
2
解决办法
720
查看次数

System.IOUtils初始化的TPath记录在哪里?

TPath记录具有类构造函数TPath.Create,它初始化类变量.但是,我找不到任何使用TPath.Create /被称为dispite的单元,所有变量都具有正确的值(TPath.PathSeparator,...).

delphi delphi-xe2

5
推荐指数
1
解决办法
433
查看次数

具有更多值和相同名称的XMLNode

我必须创建具有更多具有相同名称的值的节点的xml文档

<PstlAdr>
  <Ctry>SI</Ctry>
  <AdrLine>Gosposvetska 12</AdrLine>
  <AdrLine>Kranj</AdrLine>
</PstlAdr>
Run Code Online (Sandbox Code Playgroud)

使用oNode.ChildValues['AdrLine'] := ...它是不可能的 - 只能添加一个具有相同名称的值.如何添加更多具有相同名称的值?

最好的祝福

delphi txmldocument

5
推荐指数
1
解决办法
228
查看次数

使用Delphi连接到SQL Azure?

我无法使用Delphi 2010和dbGo连接到SQL Azure.有什么不对,怎么解决?

细节:

带有以下连接字符串的TADOConnection(登录信息已更改):

Provider=SQLNCLI10.1;Integrated Security="";Persist Security Info=False;User ID=me@tyasdgerj5;Initial Catalog=Northwind;Data Source=tcp:tyasdgerj5.database.windows.net;Initial File Name="";Server SPN=""

返回以下错误文本:

无法确定服务器名称.它必须显示为服务器的dns名称的第一个段(servername.database.windows.net).某些库不发送服务器名称,在这种情况下,服务器名称必须作为用户名(username @ servername)的一部分包含在内.此外,如果使用两种格式,则服务器名称必须匹配..

请注意,SQL Server Management Studio连接没有问题.

delphi azure-sql-database

4
推荐指数
1
解决办法
2493
查看次数

如何使用 rtti 访问类属性?

是否有可能通过 rtti 获得类属性?下面的代码有什么问题?

...
type
  TTest = class
  private
    class function GetCP: string; static;
  public
    class property CP: string read GetCP;
  end;

class function TTest.GetCP: string;
begin
  Result := 'ABC';
end;
...
procedure TForm1.Button5Click(Sender: TObject);
var
  oTest: TTest;
  oType: TRttiType;
begin
  oTest := TTest.Create;
  try
    oType := TRttiContext.Create.GetType(oTest.ClassType);
    ShowMessage(Length(oType.GetProperties).ToString);  // oType.GetProperties = nil !!! 
  finally
    oTest.Free;
  end;
end;  
Run Code Online (Sandbox Code Playgroud)

TIA 和最诚挚的问候,布兰科

delphi rtti

4
推荐指数
1
解决办法
641
查看次数

Delphi 2010 RTTI - RttiContext.FindType

随着RttiContext.FindType('Classes.TStringList')我得到的TStringList的RttiType没有问题.但是RttiContext.FindType('MyUnit.TMyClass')我总是得到零(当然MyUnit是在使用条款中).为什么,出了什么问题?

例:

unit MyUnit; 
interface 
uses 
  Classes; 
type 
  TMyClass = class(TStringList) 
  end; 
implementation 
end. 

Main unit: 
... 
uses 
  MyUnit,
... 
var 
  oCont: TRttiContext; 
  oType: TRttiType; 
begin 
  oCont := TRttiContext.Create; 
  try 
    oType := oCont.FindType('MyUnit.TMyClass'); <== oType = nil !! 
... 
Run Code Online (Sandbox Code Playgroud)

delphi rtti delphi-2010

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

TMemo后代有空行

我的TMemo后代有构造函数

constructor TMyMemo.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Lines.Clear;
end;
Run Code Online (Sandbox Code Playgroud)

当我把TMyMemo放在表单上时,我得到错误"控件''没有父窗口." 为什么?

delphi vcl

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

为什么提前创建TRttiContext使我的RTTI测试运行得更快?

链接到原始问题是否有可能获得类属性的索引?并由Remy Lebeau和RRUZ回答

program Demo;

{$APPTYPE CONSOLE}

uses
  System.SysUtils, Winapi.Windows,
  System.Rtti, System.TypInfo;

type
  TMyClass = class
  private
    function GetInteger(const Index: Integer): Integer;
    procedure SetInteger(const Index, Value: Integer);
  public
    property P1: Integer Index 1 read GetInteger write SetInteger;
    property P2: Integer Index 2 read GetInteger write SetInteger;
    property P3: Integer Index 3 read GetInteger write SetInteger;
  end;

{ TMyClass }

function TMyClass.GetInteger(const Index: Integer): Integer;
begin
  Result := Index;
end;

procedure TMyClass.SetInteger(const Index, Value: Integer);
begin
  //
end;

{------------------------------------------------------------------------------}
function …
Run Code Online (Sandbox Code Playgroud)

delphi rtti

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

调用ConvertStringSidToSid()时出现"系统错误.代码:87"

我必须在"Everyone"用户组的某个文件夹上设置prmissions,所以我需要这个组的SID.当我打电话时,ConvertStringSidToSid()我得到错误"System Error. Code: 87 - Parameter is incorrect".为什么?我的代码出了什么问题?

...
function ConvertStringSidToSid(StringSid: LPCTSTR; Sid: PSID): BOOL; stdcall;
  external Advapi32 name 'ConvertStringSidToSidW';
...
var
  Sid: PSID;
...
  Sid := Nil;
  ConvertStringSidToSid(LPCTSTR('S-1-1-0'), Sid);
...
Run Code Online (Sandbox Code Playgroud)

TIA Branko

delphi winapi windows-7 delphi-xe3

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

Delphi 2010的Crt单位

我需要用于Delphi 2010控制台应用程序的Crt单元(ReadKey,GotoXY,...).Delphi 2010是否有任何Crt单元?

delphi crt delphi-2010

-2
推荐指数
1
解决办法
2411
查看次数