Solved

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

Posted on 2006-11-09
6
220 Views
Last Modified: 2010-04-01
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.
0
Comment
Question by:lapucca
  • 3
  • 3
6 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 17909384
>>Are there any sample code on how I can do update this?

That's quite easy to figure out, since this struct (http://msdn.microsoft.com/library/en-us/ad/ad/dsdisplayspecoptions.asp) uses offsetvalues. So, if you have a pointer to it, you can just calculate the value offsets to read the values like

DSDISPLAYSPECOPTIONS* pdso = ...;

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






0
 

Author Comment

by:lapucca
ID: 17909940
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;
}
0
 

Author Comment

by:lapucca
ID: 17911184
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;
        }
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 17911201
If you don't get any errors, it should work. Have you tried running it?
0
 

Author Comment

by:lapucca
ID: 17911307
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.
0
 
LVL 86

Expert Comment

by:jkr
ID: 17911363
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...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question