2016-08-12 53 views
0

我正在開發將加密傳遞的字符串的COM對象。它將從PHP中調用。 我沒有得到如何從COM返回值到PHP。我試過下面的代碼,也許它不工作。PHP的COM對象方法

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); 
+0

'$ phpresult = $ testConnection-> EncryptURL($ sURLString,$ sEncryptedValue);'? – RamRaider

回答

0

在我看來是一個愚蠢的錯字:

new COM("URLEncryption.ATLObject") 

相比

STDMETHODIMP CATLObject::EncryptURL 
      ^^^ 

我會說new COM應該是chang編輯爲:

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