Bug #63164 [Com]: PHP extension for COM connection

From: Date: Thu, 27 Sep 2012 09:38:50 +0000
Subject: Bug #63164 [Com]: PHP extension for COM connection
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-173731@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63164&edit=1 ID: 63164 Comment by: gospodin dot p dot zh at gmail dot com Reported by: gospodin dot p dot zh at gmail dot com Summary: PHP extension for COM connection Status: Not a bug Type: Bug Package: COM related Operating System: Windows PHP Version: 5.4.7 Block user comment: N Private report: N New Comment: [2012-09-27 08:47 UTC] pajoye@php.net i need to store single (only one) instance of COM launched application for all PHP session. That's why i've started to write extension. Can you advice me good existing COM extension ? May be than i'll will use my self-male extension only to store a COM variable. Previous Comments: ------------------------------------------------------------------------ [2012-09-27 08:47:37] pajoye@php.net hi! Please ask support questions about php extension development on the PECL developer mailing list. Btw, why not contribute to the existing COM extension instead? ------------------------------------------------------------------------ [2012-09-27 08:41:54] gospodin dot p dot zh at gmail dot com i've checked memory dump, seems like strings were additionally processed for slashes as escape sequences. Here is print screen http://imageshack.us/a/img10/2097/phpu.gif ------------------------------------------------------------------------ [2012-09-26 14:28:45] gospodin dot p dot zh at gmail dot com Description: ------------ char* Connect1c77(char* dir, char* username, char* password, bool no_splash_screen){ //для начала инициализируем COM HRESULT hr = CoInitialize(NULL); if(FAILED(hr)) { return"Невозможно инициализировать COM!"; return FALSE; } CLSID cls77; hr = CLSIDFromProgID(L"V77M.Application", &cls77); if(FAILED(hr)) { return"Переустановите 1С Предприятие!"; CoUninitialize(); return FALSE; } IDispatch *pv77; hr = CoCreateInstance(cls77, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**)&pv77); if(FAILED(hr) || !pv77) { return"Невозможно инициализировать интерфейс 1С Предприятия"; CoUninitialize(); return FALSE; } VARIANT vRet; DISPID dispIDRmTrade, dispIDInitialize; DISPPARAMS args = {0, 0, 0, 0}; VARIANT vars[3]; // Параметры для вызова Initialize BSTR rmTrade = L"RMTrade"; hr = pv77->GetIDsOfNames(IID_NULL, &rmTrade, 1, 0, &dispIDRmTrade); if (FAILED(hr)) { return"Невозможно получить ID от RMTrade"; if (pv77) pv77->Release(); CoUninitialize(); return FALSE; } hr = pv77->Invoke(dispIDRmTrade, IID_NULL, 0, DISPATCH_PROPERTYGET, &args, &vars[2], NULL, NULL); if (FAILED(hr)) { return"Невозможно получить интерфейс от RMTrade"; if (pv77) pv77->Release(); CoUninitialize(); return FALSE; } //нужно получить ID для Initialize(..); BSTR init = L"Initialize"; hr = pv77->GetIDsOfNames(IID_NULL, &init, 1, 0, &dispIDInitialize); if (FAILED(hr)) { return"Не удалось получить ID от Initialize"; if (pv77) pv77->Release(); CoUninitialize(); return FALSE; } args.cArgs = 3; args.rgvarg = vars; std::wstring path = L"/DC:\\Users\\Public\\Documents\\old\\Steklo\\ /Nya /P185224"; vars[0] = _variant_t(no_splash_screen ? L"NO_SPLASH_SHOW" : L""); vars[1] = _variant_t(path.c_str());; hr = pv77->Invoke(dispIDInitialize, IID_NULL, 0, DISPATCH_PROPERTYGET, &args, &vRet, NULL, NULL); if(FAILED(hr) || (vRet.vt == VT_BOOL && vRet.bstrVal == 0x00)) { return"Невозможно запустить 1С Предприятие"; } return "ok"; } Actual result: -------------- This code work fine if compiled like Win32 application. When i make it a part of PHP extension (dll) and call from PHP script started program behaves like path std::wstring path = L"/DC:\\Users\\Public\\Documents\\old\\Steklo\\ /Nya /P185224"; is incorrect, but there is no any windows or messages of course. Stated program is in memory has size like there exists only windows to enter correct path (such window is shown if it's a win32 application, not a PHP extension). Help me somehow please ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63164&edit=1

« previous php.bugs (#173731) next »