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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>Are there any sample code on how I can do update this?

That's quite easy to figure out, since this struct ( uses offsetvalues. So, if you have a pointer to it, you can just calculate the value offsets to read the values like


LPWSTR pwszUserName = (LPWSTR)((LPBYTE)pdso + pdso->offsetUserName);
LPWSTR pwszPassword = (LPWSTR)((LPBYTE)pdso + pdso->offsetPassword);
LPWSTR pwszServer = (LPWSTR)((LPBYTE)pdso + pdso->offsetServer);
LPWSTR pwszServerConfigPath = (LPWSTR)((LPBYTE)pdso + pdso->offsetServerConfigPath);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lapuccaAuthor Commented:
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;
    LPWSTR pwszPrefix = m_pwszPrefix;
    DWORD dwPrefixOffset;

    // Size of the DSDISPLAYSPECOPTIONS structure.
    // 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);
        DSDISPLAYSPECOPTIONS *pDispSpecOptions = (DSDISPLAYSPECOPTIONS*)GlobalLock(pStgMedium->hGlobal);
            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);


            hr = S_OK;

    return hr;
lapuccaAuthor Commented:
Ok, I revser it and here it is.  I think it's correct way to set values

        DSDISPLAYSPECOPTIONS *pDispSpecOptions = (DSDISPLAYSPECOPTIONS*)GlobalLock(pStgMedium->hGlobal);
            //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);


            hr = S_OK;
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

If you don't get any errors, it should work. Have you tried running it?
lapuccaAuthor Commented:
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...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.