win7 php com dotnet,PHP 加载一个 DOTNET 模块

用户评论:

Rudi Lippert (2010-10-25 02:50:54)

If you got here looking for the standard way to load DOTNET modules, you might be better off looking here:

http://php.net/manual/en/class.dotnet.php

sunside (2007-06-30 19:46:29)

The

if (parameters[0].GetType().ToString() == "System.Int32")

below can be compacted to

if (parameters[0] is System.Int32)

as well as

if (parameters[0] is int)

(if you are on a 32bit platform, that is)

thomas dot weidner at voxtronic dot com (2002-07-23 03:54:37)

To realise functions within Microsoft.NET which can use with every type of parameter as boolean, integer, string or any other type you want to use do the following.

Write your function in .NET :

CSharp Example :

MyFunction (params object[] parameters)

{

if (parameters[0].GetType().ToString() == "System.Int32")

return "Parameter 0 is an Integer";

return "Parameter 0 is no Integer";

}

Within PHP do the following :

$parameter[0] = 12345;

$parameter[1] = "My String";

$parameter[2] = false;

$obj = new COM ("NameSpace.Class");

$value = $obj -> MyFunction($parameter)

print($value);

How to work with params and object you could read within the .NET Documentation.

If you have any further question dont be afraid and write me...

Bye

Thomas

Thomas dot Weidner at voxtronic dot com (2002-07-22 02:12:40)

mb at netminers dot dk (2002-04-29 11:34:55)

Now we are working!

Well that means that if you want to use the .NET modules, from PHP, you'll have to build a new php_dotnet.dll file.

The problem with the existing code is the interface versions of the COM object needed to mix unmanaged code with managed code.

To fix this minor issue, replace

#include "mscorlib.h", in the extensions project of the PHP4.2 source, with the following type library binary file import.

#import "mscorlib.tlb" raw_interfaces_only high_property_prefixes("_get","_put","_putref")

The type library file is converted to a type library header file which is then automatically included by Visual Studio, presuming you are using that. :o)

Have fun! (Mail me if this description was too bad, I can mail the new php_dotnet.dll)

By the way the tlbexp.exe SDK tool can generate the .tlb file.

I'll check with the PHP group to verify they are aware of the issue, so it's nicely fixed in a future release of PHP.

Great stuff,

Michael

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值