reloading dll in winbinder (php gui) crashes program

匿名 (未验证) 提交于 2019-12-03 01:42:02

问题:

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.

回答1:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!