Solved

How do I convert from "const CLSID& pPropPageCLSID" to  "CLSID *pPropPageCLSID"?

Posted on 2006-10-26
8
281 Views
Last Modified: 2008-02-01
I'm using Win32 lib only in VS 2005.  Thanks.
0
Comment
Question by:lapucca
  • 3
  • 3
  • 2
8 Comments
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17817029
CLSID& rPropPageCLSID = // asign some CLSID object;

CLSID *pPropPageCLSID = &rPropPageCLSID;
0
 
LVL 86

Expert Comment

by:jkr
ID: 17817030
Hard to tell that is the problem with that little of information, but

void DoIt(const CLSID& pPropPageCLSID) {

CLSID *pPropPageCLSID = const_cast<CLSID*>(&pPropPageCLSID);
}

should work.
0
 
LVL 12

Expert Comment

by:rajeev_devin
ID: 17817037
Don't give reference a 'p' prefix, as you have given, rather give 'r' prefix.
const CLSID& rPropPageCLSID;
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:lapucca
ID: 17817050
Sorry for not putting more information.

I am working on removing registration from code below:
In this code I need to call       
"RemovePropertyPageFromDisplaySpecifier(
    szClass, // ldapDisplayName of class.
    clsid // CLSID of property page COM object. )"
but this method's 2nd param is expecting "CLSID *pPropPageCLSID"



LONG UnregisterServer(const CLSID& clsid)       //   IDs
{
    // Get CLSID
    LPOLESTR wszCLSID = NULL,  szClass = NULL;
    HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;

      if (0 == wcscmp(wszCLSID,L"{2514CF64-0748-4b02-B188-F6588DAFD237}"))
            szClass = L"group";
      else if(0 == wcscmp(wszCLSID,L"{346488B3-6864-4864-9334-EBF5EA12528B}"))
            szClass = L"user";
      else if(0 == wcscmp(wszCLSID,L"{9E39D6BF-FBDD-4731-BFFE-741A57DDBA32}"))
            szClass = L"computer";

      RemovePropertyPageFromDisplaySpecifier(
    szClass, // ldapDisplayName of class.
    clsid // CLSID of property page COM object. )
 
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 17817061
Shouldn't that be

    RemovePropertyPageFromDisplaySpecifier(
    szClass, // ldapDisplayName of class.
    const_cast<CLSID*>(&clsid)); // CLSID of property page COM object. )

then?
0
 

Author Comment

by:lapucca
ID: 17817062
Here is the declaration:

HRESULT RemovePropertyPageFromDisplaySpecifier(
    LPOLESTR szClassName, // ldapDisplayName of class.
    CLSID *pPropPageCLSID // CLSID of property page COM object.
    );


I modified the code to below but I'm getting the same error:
Error      1      error C2440: 'initializing' : cannot convert from 'const CLSID *' to 'CLSID *'      c:\Projects\UnityExtProperty\registry.Cpp      623

Thank you.


LONG UnregisterServer(const CLSID& clsid)       //   IDs
{
    // Get CLSID
    LPOLESTR wszCLSID = NULL,  szClass = NULL;
    HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;

      if (0 == wcscmp(wszCLSID,L"{2514CF64-0748-4b02-B188-F6588DAFD237}"))
            szClass = L"group";
      else if(0 == wcscmp(wszCLSID,L"{346488B3-6864-4864-9334-EBF5EA12528B}"))
            szClass = L"user";
      else if(0 == wcscmp(wszCLSID,L"{9E39D6BF-FBDD-4731-BFFE-741A57DDBA32}"))
            szClass = L"computer";

      CLSID *pPropPageCLSID = &clsid;

      RemovePropertyPageFromDisplaySpecifier(
    szClass, // ldapDisplayName of class.
    pPropPageCLSID // CLSID of property page COM object.
    );
0
 
LVL 86

Expert Comment

by:jkr
ID: 17817064
Yup, then try the above.
0
 

Author Comment

by:lapucca
ID: 17817076
Thanks jkr,
I modifed as follow and it seems to take care of the compiling error for me.
LONG UnregisterServer(const CLSID& clsid)       //   IDs
{
    // Get CLSID
    LPOLESTR wszCLSID = NULL,  szClass = NULL;
    HRESULT hr = StringFromCLSID(clsid, &wszCLSID) ;

      if (0 == wcscmp(wszCLSID,L"{2514CF64-0748-4b02-B188-F6588DAFD237}"))
            szClass = L"group";
      else if(0 == wcscmp(wszCLSID,L"{346488B3-6864-4864-9334-EBF5EA12528B}"))
            szClass = L"user";
      else if(0 == wcscmp(wszCLSID,L"{9E39D6BF-FBDD-4731-BFFE-741A57DDBA32}"))
            szClass = L"computer";

      //CLSID *pPropPageCLSID = &clsid;
      CLSID *pPropPageCLSID = const_cast<CLSID*>(&clsid);
      RemovePropertyPageFromDisplaySpecifier(
    szClass, // ldapDisplayName of class.
    pPropPageCLSID // CLSID of property page COM object.
    );

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 56
c++ getting the first 10 characters of a char* string 11 96
gdb doesn't stop on breakpoint 2 70
show out valin of json for debugging in visaul c++ 1 34
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

825 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