【问题标题】:COM object method for PHPPHP 的 COM 对象方法
【发布时间】:2016-12-19 08:05:02
【问题描述】:

我正在开发将加密传递的字符串的 COM 对象。它将从 PHP 中调用。 我不知道如何将值从 COM 返回到 PHP。我尝试了以下代码,也许它不起作用。

 STDMETHODIMP CATLObject::EncryptURL(VARIANT* sURLString, VARIANT* sEncryptedValue)
{
    URLEncryption oURLEncryption;
    char sRequestString[MAX_NAME] = "abcbbefekjdss dsf dsk fkjds fk sd";
    char sEncrytedRequestStrin

g[MAX_NAME] = "";
    char sDecrytedRequestString[MAX_NAME] = "";

    oURLEncryption.EncryptQuery(sRequestString, sEncrytedRequestString);

    KeyValue oKeyValue1;
    KeyValue oParameterKeyValue;

    oKeyValue1.ParseKeyValueString(sEncrytedRequestString, '&', true);
    string sParameter = oKeyValue1.GetValue("sp");
    string sCheckSum = oKeyValue1.GetValue("chk");

    oURLEncryption.DecryptQuery(sParameter, sCheckSum, (void *)&oParameterKeyValue);

    string sCidAudio = oParameterKeyValue.GetValue("cid_audio");
    string sEUid = oParameterKeyValue.GetValue("euid");

    printf("sCidAudio = %s\n", sCidAudio.c_str());
    printf("sEUid = %s\n\n", sEUid.c_str());

    // Create an instance of the MEMORYSTATUSEX structure
    MEMORYSTATUSEX memstatex;

    // Specify the length of the structure
    memstatex.dwLength = sizeof(memstatex);

    // Call the GlobalMemoryStatusEx function and pass to it
    //  a reference to our MEMORYSTATUSEX instance
    ::GlobalMemoryStatusEx(&memstatex);

    // Set the ulVal (unsigned long value) of the VARIANT parameter
    //  passed by reference to the function with the dwMemoryLoad
    //   value of the MEMORYSTATUEX instance which specifies the
    //    approximate percentage of the physical memory currently
    //     in use.

    sURLString->ulVal = memstatex.dwMemoryLoad;

    sEncryptedValue->bstrVal = L"Output from DLL!!!";

    return S_OK;
}

我正在尝试通过 PHP 获取返回值

$testConnection = new COM("URLEncryption.ATLObject");

    $sURLString = new VARIANT(0, VT_UI4);
    $sEncryptedValue = new VARIANT(0, VT_UI4);

    $testConnection->EncryptURL($sURLString,$sEncryptedValue);

【问题讨论】:

  • $phpresult=$testConnection->EncryptURL($sURLString,$sEncryptedValue); ?

标签: php c++ com


【解决方案1】:

在我看来是一个愚蠢的错字:

new COM("URLEncryption.ATLObject")

相比

STDMETHODIMP CATLObject::EncryptURL
            ^^^

我想说new COM 应该改为:

$testConnection = new COM("URLEncryption.CATLObject");

【讨论】:

    猜你喜欢
    • 2011-03-05
    • 2012-08-07
    • 2012-10-20
    • 2013-09-19
    • 2016-01-30
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 2021-08-11
    相关资源
    最近更新 更多