php调用非com组件dll

https://ask.csdn.net/questions/323843

 

1. 下载dynwrap.dll
2. 把该文件放入system32和php/ext/下,修改php.ini,增加extension=dynwrap.dll
3. 注册dynwrap.dllcomcmd regsvr32 d:/dynwrap.dll
4. 将要调用的dll放入system32
5. register参数,

PHP调用代码:

<?php
$dw = new COM("DynamicWrapper");
$dw->Register("Dll1test.dll", "add", "f=s", "i=uu", "r=l");
$ch = $dw->add(11,22); //dll的add函数调用
echo'<br/>',$ch;
$dw->Register("Dll1test.dll", "subtract", "f=s", "i=uu", "r=l");
$ch2 = $dw->subtract(42,22); //dll的sub函数调用echo'<br/>',$ch2;
exit;
?>

dll1test.dll 代码:

 #define DLL1TEST_API extern "C" _declspec(dllexport)
DLL1TEST_API int add(int a,int b)
{
    return a+b;
}
DLL1TEST_API int subtract(int a,int b)
{
    return a-b;
}
posted @ 2022-11-29 13:45  宝贝皮  阅读(42)  评论(0编辑  收藏  举报