dqusbxh44823 2013-05-10 20:29
浏览 37
已采纳

在winbinder重新加载DLL(php gui)崩溃程序

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
" .
  "application that will read xml.
" .
  "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:

enter image description here

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.

  • 写回答

1条回答 默认 最新

  • douqian2524 2013-08-01 08:34
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗