在winbinder(php gui)中重新加载dll崩溃程序 [英] reloading dll in winbinder (php gui) crashes program

查看:182
本文介绍了在winbinder(php gui)中重新加载dll崩溃程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次需要加载dll nad unfortunatelly这不是COM serwer dll,所以我不能使用php com函数。



我发现它可能使用winbinder来做这个,但到目前为止我没有那么多的成功。这是我的代码:

  define(PATH_SCRIPT,dirname(__ FILE__)。/); 
define(PATH_DATA,PATH_SCRIPT);
define(PATH_INC,PATH_SCRIPTinclude /);
define(PATH_RES,PATH_SCRIPT。resources /);

// ---------------------------------------- ------------------------- DEPENDENCIES

包含PATH_INC。 winbinder.php;

// ---------------------------------------- ---------------------------- CONSTANTS

define(APPNAME,Xml Reader!); //应用程序名称

//控制标识符

define(ID_ABOUT,101);


// ------------------------------------ -------------------------- EXECUTABLE CODE

//创建主窗口,然后分配一个过程和一个图标它

$ mainwin = wb_create_window(NULL,AppWindow,APPNAME。 - PHPPHP_VERSION,320,240);
wb_set_handler($ mainwin,process_main);
wb_set_image($ mainwin,PATH_RES。hyper.ico);

//创建工具栏


wb_create_control($ mainwin,ToolBar,array(
array(ID_ABOUT,NULL,关于此应用程序),13 ),
),0,0,16,15,0,0,PATH_RES。toolbar.bmp);


//创建状态栏

$ statusbar = wb_create_control($ mainwin,StatusBar,APPNAME);

//在窗口内创建标签控件

wb_create_control($ mainwin,Label,这是xml reader\\\

将读取的应用程序xml.\\\

从dll写入文件,
10,70,290,80,0,WBC_CENTER);

//输入应用程序循环

wb_main_loop();

/ *处理主窗口命令* /



函数process_main($ window,$ id)
{
全局$ statusbar;

switch($ id){

case ID_ABOUT:
$ dll = wb_load_library(dll / OSOZMOK.dll);

// $ funcAddr = wb_get_function_address('OSOZ_Release',$ dll);
$ funcAddr = wb_get_function_address('GetDllVersion',$ dll);
$ dll_info = wb_call_function($ funcAddr);

$ funcAddr = wb_get_function_address('OSOZ_IsConnected',$ dll);
$ dll_info2 = wb_call_function($ funcAddr);

wb_release_library($ dll);

wb_message_box($ window,DLL Returned:1)$ dll_info。 2)。$ dll_info2);
break;

案例IDCLOSE:// IDCLOSE是预定义的
wb_destroy_window($ window);
break;
}


}

2件事:创建winbinder窗口,如果您点击关于它加载dll并执行2个功能。



问题是,当我再次点击程序崩溃。 ..



此外,还有一些讽刺的变量,如TRUE或FALSE,我得到了进攻。 OSOZ_IsConnected将返回常量intiger,OSOZ_Release将随机发送。



例如:





我真的怀疑dll是无论如何错误的。它必须是以我称之为函数的方式。



替代方法:是否还有其他方式在PHP中加载dll(delphi)?我想避免学习c ++ / c#来处理这个DLL,将xml输出保存到文件中,并在php:P中阅读。



对于任何可以帮助。

解决方案

似乎Winbinder根本没有足够的进步来处理这个问题。我用c ++例如



HINSTANCE hGetProcIDDLL = LoadLibrary(path_to_dll.dll); - 从windows.h





wxDynamicLibrary和.WxWidgets的.load $ /

wll都可以。


This is first time I need to load dll nad unfortunatelly this is not COM serwer dll so I can't use php com functions.

I found out it possible to use winbinder to do this, but so far I did not have that much success. Here is my code:

define("PATH_SCRIPT",   dirname(__FILE__) . "/");
define("PATH_DATA",     PATH_SCRIPT);
define("PATH_INC",      PATH_SCRIPT . "include/");
define("PATH_RES",      PATH_SCRIPT . "resources/");

//----------------------------------------------------------------- DEPENDENCIES

include PATH_INC . "winbinder.php";

//-------------------------------------------------------------------- CONSTANTS

define("APPNAME",           "Xml Reader!");    // Application name

// Control identifiers

define("ID_ABOUT",          101);


//-------------------------------------------------------------- EXECUTABLE CODE

// Create main window, then assign a procedure and an icon to it

$mainwin = wb_create_window(NULL, AppWindow, APPNAME . " - PHP " . PHP_VERSION, 320, 240);
wb_set_handler($mainwin, "process_main");
wb_set_image($mainwin, PATH_RES . "hyper.ico");

// Create toolbar


wb_create_control($mainwin, ToolBar, array(
    array(ID_ABOUT, NULL,   "About this application",   13),
), 0, 0, 16, 15, 0, 0, PATH_RES . "toolbar.bmp");


// Create status bar

$statusbar = wb_create_control($mainwin, StatusBar, APPNAME);

// Create label control inside the window

wb_create_control($mainwin, Label, "This is xml reader\n" .
  "application that will read xml.\n" .
  "from dll and write it to file.",
  10, 70, 290, 80, 0, WBC_CENTER);

// Enter application loop

wb_main_loop();

/* Process main window commands */



function process_main($window, $id)
{
    global $statusbar;

    switch($id) {

        case ID_ABOUT:
            $dll = wb_load_library("dll/OSOZMOK.dll");

            //$funcAddr = wb_get_function_address('OSOZ_Release', $dll);
            $funcAddr = wb_get_function_address('GetDllVersion', $dll);
            $dll_info = wb_call_function($funcAddr);

            $funcAddr = wb_get_function_address('OSOZ_IsConnected', $dll);
            $dll_info2 = wb_call_function($funcAddr);

            wb_release_library($dll);

            wb_message_box($window, "DLL Returned: 1) ".$dll_info. "  2) ".$dll_info2);
            break;

        case IDCLOSE:       // IDCLOSE is predefined
            wb_destroy_window($window);
            break;
    }


}

It only does 2 things: creates winbinder window and if you click "about" it loads the dll and executes 2 functions.

The problem is that whe I click about again the program crashes...

Also instead on ruturned variables like TRUE or FALSE I get intigers. OSOZ_IsConnected will return constant intiger, and OSOZ_Release will give random.

For Example:

I really doubt the dll is anyhow wrong. It must be sth with the way I call functions.

Alternative: is there any other way to load a dll (delphi) in php? I would like to avoid learning c++/c# just to handle this dll, save xml output to file, and read it in php :P.

Big thanx for anyone that can help.

解决方案

It seems that Winbinder is simply not advanced enought to handle this. I used c++. For example

HINSTANCE hGetProcIDDLL = LoadLibrary("path_to_dll.dll"); - from windows.h

OR

wxDynamicLibrary and .load from WxWidgets

wll both do.

这篇关于在winbinder(php gui)中重新加载dll崩溃程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆