Solved

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

Posted on 2006-11-09
6
215 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
Comment Utility
>>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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 86

Expert Comment

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

Author Comment

by:lapucca
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now