Osa*_*eed 13 .net delphi com winapi interop
我正在研究在Delphi程序中使用一些.NET代码,我需要使用.net程序集和预定义函数使我的程序可扩展(我已经支持常规DLL).
经过大量的在线搜索后,我找到了 Managed-VCL,但我还没准备好为我需要支付250美元,我还发现了一些代码不完整但不起作用的新闻组.
我正在使用Delphi 2007 for win32.我可以使用什么来从具有预定义参数的程序集动态执行函数?
就像是:
procedure ExecAssembly(AssemblyFileName:String; Parameters: Variant);
Run Code Online (Sandbox Code Playgroud)
我只想补充一点,我需要能够加载任意程序集(可能是特定文件夹中的所有程序集),因此创建C#包装器可能无法正常工作.
在Jedi代码库(JCL) - 免费 - 有一个JclDotNet.pas,包含一个类TJclClrHost,可能正在做你想要的:
TJclClrHost = class(TJclClrBase, ICorRuntimeHost)
private
FDefaultInterface: ICorRuntimeHost;
FAppDomains: TObjectList;
procedure EnumAppDomains;
function GetAppDomain(const Idx: Integer): TJclClrAppDomain;
function GetAppDomainCount: Integer;
function GetDefaultAppDomain: IJclClrAppDomain;
function GetCurrentAppDomain: IJclClrAppDomain;
protected
function AddAppDomain(const AppDomain: TJclClrAppDomain): Integer;
function RemoveAppDomain(const AppDomain: TJclClrAppDomain): Integer;
public
constructor Create(const ClrVer: WideString = '';
const Flavor: TJclClrHostFlavor = hfWorkStation;
const ConcurrentGC: Boolean = True;
const LoaderFlags: TJclClrHostLoaderFlags = [hlOptSingleDomain]);
destructor Destroy; override;
procedure Start;
procedure Stop;
procedure Refresh;
function CreateDomainSetup: TJclClrAppDomainSetup;
function CreateAppDomain(const Name: WideString;
const Setup: TJclClrAppDomainSetup = nil;
const Evidence: IJclClrEvidence = nil): TJclClrAppDomain;
function FindAppDomain(const Intf: IJclClrAppDomain; var Ret: TJclClrAppDomain): Boolean; overload;
function FindAppDomain(const Name: WideString; var Ret: TJclClrAppDomain): Boolean; overload;
class function CorSystemDirectory: WideString;
class function CorVersion: WideString;
class function CorRequiredVersion: WideString;
class procedure GetClrVersions(VersionNames: TWideStrings); overload;
class procedure GetClrVersions(VersionNames: TStrings); overload;
property DefaultInterface: ICorRuntimeHost read FDefaultInterface implements ICorRuntimeHost;
property AppDomains[const Idx: Integer]: TJclClrAppDomain read GetAppDomain; default;
property AppDomainCount: Integer read GetAppDomainCount;
property DefaultAppDomain: IJclClrAppDomain read GetDefaultAppDomain;
property CurrentAppDomain: IJclClrAppDomain read GetCurrentAppDomain;
end;
Run Code Online (Sandbox Code Playgroud)
我可以从第一手经验告诉你,与Delphi的.Net互操作不是野餐.我是.Net的人,但在.Net和Delphi商店工作了一段时间.我管理了几个用.Net(WinForms和WPF)编写但被Delphi调用的项目.我们的Delphi人员已经为Delphi编写了一个互操作层,可以调用.Net库,因为我们所有的新产品都是用.Net编写的.这对我们来说很麻烦(这些都是优秀的Delphi开发人员).如果我们本可以购买一个好的第三方图书馆为我们做互操作,那将是非常值得的.我敢打赌,我们花了数千美元用于从Delphi到.Net的互操作编写和调试问题.
我会把Managed-VLC库用于试驾,看看它的工作情况.如果它不辜负它的广告,那么它很容易就值250美元.
| 归档时间: |
|
| 查看次数: |
7748 次 |
| 最近记录: |