[C#] Calling An Office DLL Help

Discussion in 'Mixed Languages' started by CODYQX4, Dec 7, 2010.

  1. deagles

    deagles MDL Developer

    Feb 22, 2013
    239
    1,174
    10
    #21 deagles, May 3, 2013
    Last edited by a moderator: Apr 20, 2017
    Code:
                byte[] descBuffer = new byte[4];
                SLDATATYPE slDataType = SLDATATYPE.SL_DATA_DWORD;
                NativeMethods.SPPGetApplicationInformation(sppHandle, ref windowsAppID, "RemainingRearmCount", ref slDataType, ref descSize, ref descBuffer);
    
                // Close Handle to Microsoft Windows Software Licensing Service
                NativeMethods.SPPClose(sppHandle);
                NativeMethods.FreeLibrary(sppDllHandle);
    
                // Return Rearm Count
                return descBuffer[0];
    
    
    You return the least significant byte from descBuffer.

    descSize && descBuffer are both output.
    SLGetApplicationInformation allocates descBuffer and sets descSize.
     
  2. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,814
    45,768
    150
    #22 CODYQX4, May 3, 2013
    Last edited: Apr 12, 2019
    (OP)
    .
     
  3. deagles

    deagles MDL Developer

    Feb 22, 2013
    239
    1,174
    10
    #23 deagles, May 3, 2013
    Last edited by a moderator: Apr 20, 2017
    Yes like in my c++ source:

    Code:
        UINT descSize;
        PBYTE descBuffer;
        if(_SLGetApplicationInformation(hslcOSPP,  (SLID*)Office2013GUID, L"RemainingRearmCount", NULL, &descSize,  &descBuffer) != S_OK)
            wprintf_s(L"osppc.SLGetApplicationInformation\n\n");
        else{
            StringCbPrintf(msg, MAX_MSG_SIZE, L"RemainingRearmCount (Office 2013): %d\n\n", *(DWORD*)descBuffer);
            wprintf_s(msg);
            LocalFree(descBuffer);
        }
    
    
     
  4. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,814
    45,768
    150
    #24 CODYQX4, May 3, 2013
    Last edited: Apr 12, 2019
    (OP)
    .