Solved

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

Posted on 2006-11-09
6
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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!

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.

734 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