Link to home
Start Free TrialLog in
Avatar of lapucca
lapucca

asked on

Any sample on how to change the DSDISPLAYSPECOPTIONS for ext prop page

The CFSTR_DS_DISPLAY_SPEC_OPTIONS clipboard format provides an HGLOBAL that contains a DSDISPLAYSPECOPTIONS structure. The DSDISPLAYSPECOPTIONS contains configuration data for use by the extension.

I think I need to change the the user, password, server path in this structure for all the adminPropertyPages in the display specifier.  Are there any sample code on how I can do update this?
--
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lapucca
lapucca

ASKER

Here is how they get the values, but I need code to "set" the values, Thanks.


HRESULT CPropSheetHost::_GetDSDispSpecOption(FORMATETC *pFormatEtc,
                                             STGMEDIUM *pStgMedium)
{
    if((m_cfDSDispSpecOptions != pFormatEtc->cfFormat) ||
        !(pFormatEtc->tymed & TYMED_HGLOBAL))
    {
        return DV_E_FORMATETC;
    }
   
    HRESULT hr = E_OUTOFMEMORY;
    LPWSTR pwszPrefix = m_pwszPrefix;
    DWORD dwPrefixOffset;

    // Size of the DSDISPLAYSPECOPTIONS structure.
    DWORD dwBytes = sizeof(DSDISPLAYSPECOPTIONS);
   
    // Store the offset to the prefix.
    dwPrefixOffset = dwBytes;
   
    // Length of the prefix Unicode string, including the null terminator.
    dwBytes += (lstrlenW(pwszPrefix) + 1) * sizeof(WCHAR);

    pStgMedium->pUnkForRelease = NULL;
    pStgMedium->tymed = TYMED_HGLOBAL;
    pStgMedium->hGlobal = GlobalAlloc(GPTR, dwBytes);
    if(pStgMedium->hGlobal)
    {
        DSDISPLAYSPECOPTIONS *pDispSpecOptions = (DSDISPLAYSPECOPTIONS*)GlobalLock(pStgMedium->hGlobal);
        if(pDispSpecOptions)
        {
            LPWSTR pwszTemp;


            pDispSpecOptions->dwSize = sizeof(DSDISPLAYSPECOPTIONS);
            pDispSpecOptions->dwFlags = 0;
            pDispSpecOptions->offsetAttribPrefix = dwPrefixOffset;
            pDispSpecOptions->offsetUserName = 0;
            pDispSpecOptions->offsetPassword = 0;
            pDispSpecOptions->offsetServer = 0;
            pDispSpecOptions->offsetServerConfigPath = 0;
           
            // Copy the prefix string.
            pwszTemp = (LPWSTR)((LPBYTE)pDispSpecOptions + dwPrefixOffset);
            lstrcpyW(pwszTemp, pwszPrefix);

            GlobalUnlock(pStgMedium->hGlobal);

            hr = S_OK;
        }
    }

    return hr;
}
Avatar of lapucca

ASKER

Ok, I revser it and here it is.  I think it's correct way to set values

    if(pStgMedium->hGlobal)
    {
        DSDISPLAYSPECOPTIONS *pDispSpecOptions = (DSDISPLAYSPECOPTIONS*)GlobalLock(pStgMedium->hGlobal);
        if(pDispSpecOptions)
        {
            //LPWSTR pwszTemp;

            pDispSpecOptions->dwFlags = DSDSOF_HASUSERANDSERVERINFO;
                  wcscpy((LPWSTR)((LPBYTE)pDispSpecOptions + pDispSpecOptions->offsetAttribPrefix), pwszPrefix);
                  wcscpy((LPWSTR)((LPBYTE)pDispSpecOptions + pDispSpecOptions->offsetUserName), m_userID);
                  wcscpy((LPWSTR)((LPBYTE)pDispSpecOptions + pDispSpecOptions->offsetPassword), m_password);
                  wcscpy((LPWSTR)((LPBYTE)pDispSpecOptions + pDispSpecOptions->offsetServer), m_serverName);
                  wcscpy((LPWSTR)((LPBYTE)pDispSpecOptions + pDispSpecOptions->offsetServerConfigPath), m_adPath);
           
            // Copy the prefix string.
            //pwszTemp = (LPWSTR)((LPBYTE)pDispSpecOptions + dwPrefixOffset);
            //lstrcpyW(pwszTemp, pwszPrefix);

            GlobalUnlock(pStgMedium->hGlobal);

            hr = S_OK;
        }
If you don't get any errors, it should work. Have you tried running it?
Avatar of lapucca

ASKER

Yes, and it compiles OK.  Thank you.  I'm posting another related question.  I would appreciate it if you can take a look too.  Thanks.
Just a caveat - after thinking about thar whole thing, you might run into trouble seeting these values successfully if they are larger than teh previous ones...