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.

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

报告相同问题?

悬赏问题

  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state