使用Typinfo单元,可以轻松枚举属性,如以下代码段所示:
procedure TYRPropertiesMap.InitFrom(AClass: TClass; InheritLevel: Integer = 0);
var
propInfo: PPropInfo;
propCount: Integer;
propList: PPropList;
propType: PPTypeInfo;
pm: TYRPropertyMap;
classInfo: TClassInfo;
ix: Integer;
begin
ClearMap;
propCount := GetPropList(PTypeInfo(AClass.ClassInfo), propList);
for ix := 0 to propCount - 1 do
begin
propInfo := propList^[ix];
propType := propInfo^.PropType;
if propType^.Kind = tkMethod then
Continue; // Skip methods
{ Need to get GetPropInheritenceIndex to work
if GetPropInheritenceIndex(propInfo) > InheritLevel then
Continue; // Dont include properties deeper than InheritLevel
}
pm := TYRPropertyMap.Create(propInfo.Name);
FList.Add(pm);
end; …Run Code Online (Sandbox Code Playgroud) 我有一些MSVC++编译的DLL,我已经创建了COM-like(lite)接口(抽象的Delphi类).其中一些类具有需要指向对象的指针的方法.这些C++方法是使用__thiscall调用约定(我无法更改)声明的,就像__stdcall一样,除了这个指针在ECX寄存器上传递.
我在Delphi中创建类实例,然后将其传递给C++方法.我可以在Delphi中设置断点并看到它在我的Delphi类中遇到暴露的__stdcall方法,但很快我得到一个STATUS_STACK_BUFFER_OVERRUN并且应用程序必须退出.是否可以在Delphi方面模拟/处理__thiscall?如果我传递一个由C++系统实例化的对象,那么一切都很好,并调用该对象的方法(如预期的那样),但这没用 - 我需要传递Delphi对象.
编辑2010-04-19 18:12这就是更详细的情况:第一个调用的方法(setLabel)退出时没有错误(尽管它是一个存根方法).第二种方法叫做(init),然后在尝试读取vol参数时进入 .
C++ Side
#define SHAPES_EXPORT __declspec(dllexport) // just to show the value
class SHAPES_EXPORT CBox
{
public:
virtual ~CBox() {}
virtual void init(double volume) = 0;
virtual void grow(double amount) = 0;
virtual void shrink(double amount) = 0;
virtual void setID(int ID = 0) = 0;
virtual void setLabel(const char* text) = 0;
};
Run Code Online (Sandbox Code Playgroud)
德尔福方面
IBox = class
public
procedure destroyBox; virtual; stdcall; abstract;
procedure …Run Code Online (Sandbox Code Playgroud) 我想从Eclipse 3.6.1中的选项卡中删除关闭按钮.关闭按钮是不必要的(中间单击关闭选项卡)和烦人(使得很容易意外关闭标签).此外,当发生鼠标悬停事件时,为每个关闭按钮保留空间,以使标签比必要的更宽.
是否有一些调整/黑客可以禁用此功能?
谢谢.
我一直在尝试从MSVC++中编译的DLL中捕获stdout和stderr输出,这是我的Delphi应用程序静态链接到的,但到目前为止都没有成功.
procedure Test;
var
fs: TFileStream;
begin
fs := TFileStream.Create('C:\temp\output.log', fmCreate or fmShareDenyWrite);
SetStdHandle(STD_OUTPUT_HANDLE, fs.Handle);
SetStdHandle(STD_ERROR_HANDLE, fs.Handle);
dllFunc(0); // Writes to stdout in MSVC++ console app, but not here
// fs.Length is always zero
fs.Free;
end;
Run Code Online (Sandbox Code Playgroud)
以为我在正确的轨道上,但它不起作用.
任何帮助,将不胜感激.
我跟随了Rudy Velthuis关于在DLL中使用C++类的优秀文章.一切都很好,除了我需要访问一些在C++ DLL中没有相应工厂的类.如何在DLL中构造类的实例?有问题的类定义为
class __declspec(dllexport) exampleClass
{
public:
void foo();
};
Run Code Online (Sandbox Code Playgroud)
现在没有工厂,我没有明确的方法来实例化类,但我知道它可以完成,因为我已经看到了使这些类可用于Python的SWIG脚本(.i文件).如果Python和SWIG可以做到,那么我假设/希望有一些方法可以在Delphi中实现它.
现在我对SWIG知之甚少,但它似乎为C++错位名称生成某种映射?那附近哪儿好吗?看看DLL的导出,我想我可以直接通过索引或错误的名称来访问函数和构造函数/析构函数,但这样会很讨厌; 它会工作吗?即使我可以调用构造函数,我该怎么做相当于"new CClass();" 在德尔福?
MariaDB 是否支持嵌套事务(不是保存点)?
我希望能够在存储过程中使用嵌套事务。目前在 MySQL 中,我将一个参数“useTransaction”传递给每个存储过程,它控制我是否在该存储过程的主体中启动一个新事务。
如果事务可以像这样嵌套会更方便。