Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Access Denied in VC++ COM

Access Denied in VC++ COM

Scheduled Pinned Locked Moved COM
helpc++comsysadminperformance
21 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RevathiRamakumar
    wrote on last edited by
    #1

    Hi all...I have a server Component which is a inprocess exe and a dialog based client... Server has 3 methods ..One method returning CPU usuage , other method returning the memory usuage and the third method just returns a BSTR String... In client code ,when I try to call the third method(returns the BSTR srting) I get Access Denied error.. How can I overcome this issue...:confused: Thank u.. Here's my sample code..(Client). CoInitialize(NULL); HRESULT hr = NULL,hr1=NULL; IGetStatus* pGetStatus; hr=CoCreateInstance(CLSID_GetStatus,NULL,CLSCTX_LOCAL_SERVER,IID_IGetStatus,(void **)&pGetStatus); if(SUCCEEDED(hr)) { try { _bstr_t str1 ; str1 = pGetStatus->GetBeat(); char* Text = _com_util::ConvertBSTRToString(str1); AfxMessageBox(Text); ::SysFreeString(str1); UINT CPU_Info = pGetStatus->Get_CPU(); int Memory_Info = pGetStatus->Get_Memory(); } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP); } }

    R V 2 Replies Last reply
    0
    • R RevathiRamakumar

      Hi all...I have a server Component which is a inprocess exe and a dialog based client... Server has 3 methods ..One method returning CPU usuage , other method returning the memory usuage and the third method just returns a BSTR String... In client code ,when I try to call the third method(returns the BSTR srting) I get Access Denied error.. How can I overcome this issue...:confused: Thank u.. Here's my sample code..(Client). CoInitialize(NULL); HRESULT hr = NULL,hr1=NULL; IGetStatus* pGetStatus; hr=CoCreateInstance(CLSID_GetStatus,NULL,CLSCTX_LOCAL_SERVER,IID_IGetStatus,(void **)&pGetStatus); if(SUCCEEDED(hr)) { try { _bstr_t str1 ; str1 = pGetStatus->GetBeat(); char* Text = _com_util::ConvertBSTRToString(str1); AfxMessageBox(Text); ::SysFreeString(str1); UINT CPU_Info = pGetStatus->Get_CPU(); int Memory_Info = pGetStatus->Get_Memory(); } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP); } }

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #2

      RevathiRamakumar wrote:

      I have a server Component which is a inprocess exe

      Ummm, I think not... If it's an EXE it is out-of-process. Try and change CLSCTX_LOCAL_SERVER in the call to ::CoCreateInstance() into CLSCTX_INPROC_SERVER and the call will most likely fail.

      RevathiRamakumar wrote:

      IGetStatus* pGetStatus;
      ....
      str1 = pGetStatus->GetBeat();

      It looks like you're using the raw COM interface and not a wrapper for dispatch interfaces. If this is the case you're violating the COM rule that says every function must return a HRESULT. Thus you cannot return a string, it has to be an output parameter. How is your IGetStatus::GetBeat() interface function declared in the IDL-file? What attributes have you added to your IGetStatus interface? "oleautomation"? Is your IGetStatus interface declared as a "dispinterface" or just "interface" in the IDL-file? I would suggest that you declare your IGetStatus interface as an ordinary interface using the "interface" keyword in the IDL-file, but add the "oleautomation" attribute in order to use typelib-marshalling. The benefit is that you don't have to worry about how the interface is marshalled, but the downside is that you're restricted to use automation compatible data types such as BSTR (any type that can be contained in a VARIANT). Then your interface function declaration should look something like this:

      HRESULT GetBeat( [out] BSTR* pTheBeat );

      and you should call it some way similar to this:

      BSTR* pbstrTheBeat = NULL;
      hr = pGetStatus->GetStatus( pbstrTheBeat ); // pGetStatus is the interface pointer
      if( SUCCEEDED( hr ) )
      {
      // The call was successful, do whatever you like with the string
      ::SysFreeString( pbstrTheBeat ); // Since it was allocated by the server or stub
      }

      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      R 1 Reply Last reply
      0
      • R Roger Stoltz

        RevathiRamakumar wrote:

        I have a server Component which is a inprocess exe

        Ummm, I think not... If it's an EXE it is out-of-process. Try and change CLSCTX_LOCAL_SERVER in the call to ::CoCreateInstance() into CLSCTX_INPROC_SERVER and the call will most likely fail.

        RevathiRamakumar wrote:

        IGetStatus* pGetStatus;
        ....
        str1 = pGetStatus->GetBeat();

        It looks like you're using the raw COM interface and not a wrapper for dispatch interfaces. If this is the case you're violating the COM rule that says every function must return a HRESULT. Thus you cannot return a string, it has to be an output parameter. How is your IGetStatus::GetBeat() interface function declared in the IDL-file? What attributes have you added to your IGetStatus interface? "oleautomation"? Is your IGetStatus interface declared as a "dispinterface" or just "interface" in the IDL-file? I would suggest that you declare your IGetStatus interface as an ordinary interface using the "interface" keyword in the IDL-file, but add the "oleautomation" attribute in order to use typelib-marshalling. The benefit is that you don't have to worry about how the interface is marshalled, but the downside is that you're restricted to use automation compatible data types such as BSTR (any type that can be contained in a VARIANT). Then your interface function declaration should look something like this:

        HRESULT GetBeat( [out] BSTR* pTheBeat );

        and you should call it some way similar to this:

        BSTR* pbstrTheBeat = NULL;
        hr = pGetStatus->GetStatus( pbstrTheBeat ); // pGetStatus is the interface pointer
        if( SUCCEEDED( hr ) )
        {
        // The call was successful, do whatever you like with the string
        ::SysFreeString( pbstrTheBeat ); // Since it was allocated by the server or stub
        }

        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
        "High speed never compensates for wrong direction!" - unknown

        R Offline
        R Offline
        RevathiRamakumar
        wrote on last edited by
        #3

        Hi.. Thanks for the help extended...I have added oleautomation...its an ordinary Interface.. I tried ur suggestion.. But,in the following code I get error ... BSTR* pbstrTheBeat = NULL; hr = pGetStatus->GetBeat(pbstrTheBeat); C2660: 'Get_Beat' : function does not take 1 parameters The prototype and the definition are similar and they just return a single value only..And also the intelligence shows me two methods ie 1.HRESULT raw_Get_Beat(BSTR*) and 2._bstr_t GetBeat(). When I use hr = pGetStatus->raw_Get_Beat(pbstrTheBeat) I dont get any error..But, HRESULT fails.. Why is that so?I dont understand...Can u please help me.. Thank u..

        modified on Tuesday, March 31, 2009 2:33 AM

        R 1 Reply Last reply
        0
        • R RevathiRamakumar

          Hi.. Thanks for the help extended...I have added oleautomation...its an ordinary Interface.. I tried ur suggestion.. But,in the following code I get error ... BSTR* pbstrTheBeat = NULL; hr = pGetStatus->GetBeat(pbstrTheBeat); C2660: 'Get_Beat' : function does not take 1 parameters The prototype and the definition are similar and they just return a single value only..And also the intelligence shows me two methods ie 1.HRESULT raw_Get_Beat(BSTR*) and 2._bstr_t GetBeat(). When I use hr = pGetStatus->raw_Get_Beat(pbstrTheBeat) I dont get any error..But, HRESULT fails.. Why is that so?I dont understand...Can u please help me.. Thank u..

          modified on Tuesday, March 31, 2009 2:33 AM

          R Offline
          R Offline
          Roger Stoltz
          wrote on last edited by
          #4

          You probably have the "dual" attribute added to the interface. If this is the case you should remove it. The dual attribute mean that a client can use the interface as an ordinary COM virtual table based interface and as a dispatch (automation) interface. Read more here[^]. When the typelib is imported and the interface is a "dual" interface, two functions will be declared for each interface function; one for the dispinterface and one for the "raw" virtual table based interface. If you add the "raw_interfaces_only" attribute to the #import you tell the preprocessor to declare functions only for the vtable based part of the interface. Read more here[^].

          RevathiRamakumar wrote:

          When I use hr = pGetStatus->raw_Get_Beat(pbstrTheBeat) I dont get any error..But, HRESULT fails..

          If you add the "raw_interfaces_only" attribute, the "raw" prefix will be removed from the name of this function. So, the call fails.... What is the error code and what do you suspect may be wrong?

          "It's supposed to be hard, otherwise anybody could do it!" - selfquote
          "High speed never compensates for wrong direction!" - unknown

          R 1 Reply Last reply
          0
          • R Roger Stoltz

            You probably have the "dual" attribute added to the interface. If this is the case you should remove it. The dual attribute mean that a client can use the interface as an ordinary COM virtual table based interface and as a dispatch (automation) interface. Read more here[^]. When the typelib is imported and the interface is a "dual" interface, two functions will be declared for each interface function; one for the dispinterface and one for the "raw" virtual table based interface. If you add the "raw_interfaces_only" attribute to the #import you tell the preprocessor to declare functions only for the vtable based part of the interface. Read more here[^].

            RevathiRamakumar wrote:

            When I use hr = pGetStatus->raw_Get_Beat(pbstrTheBeat) I dont get any error..But, HRESULT fails..

            If you add the "raw_interfaces_only" attribute, the "raw" prefix will be removed from the name of this function. So, the call fails.... What is the error code and what do you suspect may be wrong?

            "It's supposed to be hard, otherwise anybody could do it!" - selfquote
            "High speed never compensates for wrong direction!" - unknown

            R Offline
            R Offline
            RevathiRamakumar
            wrote on last edited by
            #5

            Thank u..Ho it seems I need to know alot...I tried the following... BSTR* pbstrTheBeat = NULL; hr1 = pGetStatus->raw_Get_Beat(pbstrTheBeat); if( SUCCEEDED( hr1 ) ) //-2147023116 { AfxMessageBox("Text"); } else { _com_error e(hr1); AfxMessageBox(e.ErrorMessage()); } And I got the error message ...A null pointer reference was passed to stub... hr1=-2147023116 :doh:

            R 1 Reply Last reply
            0
            • R RevathiRamakumar

              Thank u..Ho it seems I need to know alot...I tried the following... BSTR* pbstrTheBeat = NULL; hr1 = pGetStatus->raw_Get_Beat(pbstrTheBeat); if( SUCCEEDED( hr1 ) ) //-2147023116 { AfxMessageBox("Text"); } else { _com_error e(hr1); AfxMessageBox(e.ErrorMessage()); } And I got the error message ...A null pointer reference was passed to stub... hr1=-2147023116 :doh:

              R Offline
              R Offline
              Roger Stoltz
              wrote on last edited by
              #6

              RevathiRamakumar wrote:

              And I got the error message ...A null pointer reference was passed to stub...

              Oops... Sorry about that, must have been a temporary brain hiccup. :-\ The error makes perfectly sense if you think about it, how is the caller suppose to get the result.... Of course it should be:

              BSTR bstrTheBeat = NULL;
              hr = pGetStatus->GetBeat( &bstrTheBeat ); // pGetStatus is the interface pointer
              if( SUCCEEDED( hr ) )
              {
              // The call was successful, do whatever you like with the string
              ::SysFreeString( bstrTheBeat ); // Since it was allocated by the server or stub
              bstrTheBeat = NULL;
              }

              "It's supposed to be hard, otherwise anybody could do it!" - selfquote
              "High speed never compensates for wrong direction!" - unknown

              R 1 Reply Last reply
              0
              • R Roger Stoltz

                RevathiRamakumar wrote:

                And I got the error message ...A null pointer reference was passed to stub...

                Oops... Sorry about that, must have been a temporary brain hiccup. :-\ The error makes perfectly sense if you think about it, how is the caller suppose to get the result.... Of course it should be:

                BSTR bstrTheBeat = NULL;
                hr = pGetStatus->GetBeat( &bstrTheBeat ); // pGetStatus is the interface pointer
                if( SUCCEEDED( hr ) )
                {
                // The call was successful, do whatever you like with the string
                ::SysFreeString( bstrTheBeat ); // Since it was allocated by the server or stub
                bstrTheBeat = NULL;
                }

                "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                "High speed never compensates for wrong direction!" - unknown

                R Offline
                R Offline
                RevathiRamakumar
                wrote on last edited by
                #7

                Thank u... NO It doesn't work... error C2664: 'raw_GetBeat' : cannot convert parameter 1 from 'unsigned short *** ' to 'unsigned short ** ' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast. So, I tried this one.. hr1 = pGetStatus->raw_GetBeat((BSTR*)&pbstrTheBeat); But, still I get ACCESS DENIED... :doh:

                R 1 Reply Last reply
                0
                • R RevathiRamakumar

                  Thank u... NO It doesn't work... error C2664: 'raw_GetBeat' : cannot convert parameter 1 from 'unsigned short *** ' to 'unsigned short ** ' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast. So, I tried this one.. hr1 = pGetStatus->raw_GetBeat((BSTR*)&pbstrTheBeat); But, still I get ACCESS DENIED... :doh:

                  R Offline
                  R Offline
                  Roger Stoltz
                  wrote on last edited by
                  #8

                  RevathiRamakumar wrote:

                  cannot convert parameter 1 from 'unsigned short *** ' to 'unsigned short **

                  Read my code snippet again. The type has changed from BSTR* to a simple BSTR compared to the code snippet in my previous post.

                  "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                  "High speed never compensates for wrong direction!" - unknown

                  R 1 Reply Last reply
                  0
                  • R Roger Stoltz

                    RevathiRamakumar wrote:

                    cannot convert parameter 1 from 'unsigned short *** ' to 'unsigned short **

                    Read my code snippet again. The type has changed from BSTR* to a simple BSTR compared to the code snippet in my previous post.

                    "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                    "High speed never compensates for wrong direction!" - unknown

                    R Offline
                    R Offline
                    RevathiRamakumar
                    wrote on last edited by
                    #9

                    Ho extremely sorry...Now no errors..But y is the access denied...sorry to bug u alot..Thank u..

                    R R 2 Replies Last reply
                    0
                    • R RevathiRamakumar

                      Ho extremely sorry...Now no errors..But y is the access denied...sorry to bug u alot..Thank u..

                      R Offline
                      R Offline
                      RevathiRamakumar
                      wrote on last edited by
                      #10

                      Is there something to do with the firewall settings...I'm not sure if firewall settings has to something with COM..Thank u in advance..

                      R 1 Reply Last reply
                      0
                      • R RevathiRamakumar

                        Is there something to do with the firewall settings...I'm not sure if firewall settings has to something with COM..Thank u in advance..

                        R Offline
                        R Offline
                        Roger Stoltz
                        wrote on last edited by
                        #11

                        RevathiRamakumar wrote:

                        Is there something to do with the firewall settings...I'm not sure if firewall settings has to something with COM.

                        If you would be using DCOM, Distributed COM, where the server and client resides on different machines, a network firewall may present some troubles. Some firewalls, such as Comodo, could prevent the client process from accessing the server process or ask the user for action. However, I very much doubt any firewall would cause any troubles in your case since you're able to successfully call other functions of the same interface of the same server.

                        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                        "High speed never compensates for wrong direction!" - unknown

                        1 Reply Last reply
                        0
                        • R RevathiRamakumar

                          Ho extremely sorry...Now no errors..But y is the access denied...sorry to bug u alot..Thank u..

                          R Offline
                          R Offline
                          Roger Stoltz
                          wrote on last edited by
                          #12

                          RevathiRamakumar wrote:

                          Ho extremely sorry...

                          No worries, you were not the only one who made a mistake.

                          RevathiRamakumar wrote:

                          Now no errors..

                          Good.

                          RevathiRamakumar wrote:

                          But y is the access denied

                          What are you trying to do when do you experience this? Have you tried to debug it and step though the code? Does the BSTR variable point to a valid string? What does the source code look like where you get this error?

                          "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                          "High speed never compensates for wrong direction!" - unknown

                          R 1 Reply Last reply
                          0
                          • R Roger Stoltz

                            RevathiRamakumar wrote:

                            Ho extremely sorry...

                            No worries, you were not the only one who made a mistake.

                            RevathiRamakumar wrote:

                            Now no errors..

                            Good.

                            RevathiRamakumar wrote:

                            But y is the access denied

                            What are you trying to do when do you experience this? Have you tried to debug it and step though the code? Does the BSTR variable point to a valid string? What does the source code look like where you get this error?

                            "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                            "High speed never compensates for wrong direction!" - unknown

                            R Offline
                            R Offline
                            RevathiRamakumar
                            wrote on last edited by
                            #13

                            Thanks for ur reply..Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception... HRESULT hr1; hr1 = pGetStatus->raw_Get_Beat(&pbstrTheBeat);//This raises Access Denied /*BSTR does not point to a valid String..It shows 0xc000000 */ if( SUCCEEDED( hr1 ) ) { AfxMessageBox("Text"); } else { _com_error e(hr1); AfxMessageBox(e.ErrorMessage()); } } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP);//This tells me ACCESS IS DENIED } I tried to debug..Actually the purpose is that I need to get the CPU and Memory usuage of a Server machine which is remote..I wanted to try it on a local machine first and then to implement on a remote machine..But, in the local machine itself I get Access Denied..Can u please tell me how to solve this...Thank u in advance...

                            R 1 Reply Last reply
                            0
                            • R RevathiRamakumar

                              Thanks for ur reply..Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception... HRESULT hr1; hr1 = pGetStatus->raw_Get_Beat(&pbstrTheBeat);//This raises Access Denied /*BSTR does not point to a valid String..It shows 0xc000000 */ if( SUCCEEDED( hr1 ) ) { AfxMessageBox("Text"); } else { _com_error e(hr1); AfxMessageBox(e.ErrorMessage()); } } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP);//This tells me ACCESS IS DENIED } I tried to debug..Actually the purpose is that I need to get the CPU and Memory usuage of a Server machine which is remote..I wanted to try it on a local machine first and then to implement on a remote machine..But, in the local machine itself I get Access Denied..Can u please tell me how to solve this...Thank u in advance...

                              R Offline
                              R Offline
                              Roger Stoltz
                              wrote on last edited by
                              #14

                              RevathiRamakumar wrote:

                              Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception...

                              :confused: I assumed you were able to call the two other functions successfully since you wrote

                              RevathiRamakumar wrote:

                              when I try to call the third method(returns the BSTR srting) I get Access Denied error.

                              in your original post. I suggest you unregister the server, rebuild the complete server and register it. Clean up the client project, and especially the files generated when #importing the typelib of the server. Rebuild the client, debug it and verify that the server can be successfully created, i.e. make sure that the HRESULT returned from ::CoCreateInstance() equals zero and your interface pointer points to a valid address. Also make sure you have the named_guids attribute when #importing since this will declare the CLSID and IIDs correctly for you.

                              "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                              "High speed never compensates for wrong direction!" - unknown

                              R 1 Reply Last reply
                              0
                              • R Roger Stoltz

                                RevathiRamakumar wrote:

                                Actually I couldn't call any of the methods in the interface..Whenever I try to call any of these methods I get Access denied exception...

                                :confused: I assumed you were able to call the two other functions successfully since you wrote

                                RevathiRamakumar wrote:

                                when I try to call the third method(returns the BSTR srting) I get Access Denied error.

                                in your original post. I suggest you unregister the server, rebuild the complete server and register it. Clean up the client project, and especially the files generated when #importing the typelib of the server. Rebuild the client, debug it and verify that the server can be successfully created, i.e. make sure that the HRESULT returned from ::CoCreateInstance() equals zero and your interface pointer points to a valid address. Also make sure you have the named_guids attribute when #importing since this will declare the CLSID and IIDs correctly for you.

                                "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                                "High speed never compensates for wrong direction!" - unknown

                                R Offline
                                R Offline
                                RevathiRamakumar
                                wrote on last edited by
                                #15

                                Thanks for the reply Roger..I tried the way u suggested.. I unregistered the server ,built it again and then registered it..I also cleaned up the client and tried to built it again..HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method... :(

                                R 1 Reply Last reply
                                0
                                • R RevathiRamakumar

                                  Hi all...I have a server Component which is a inprocess exe and a dialog based client... Server has 3 methods ..One method returning CPU usuage , other method returning the memory usuage and the third method just returns a BSTR String... In client code ,when I try to call the third method(returns the BSTR srting) I get Access Denied error.. How can I overcome this issue...:confused: Thank u.. Here's my sample code..(Client). CoInitialize(NULL); HRESULT hr = NULL,hr1=NULL; IGetStatus* pGetStatus; hr=CoCreateInstance(CLSID_GetStatus,NULL,CLSCTX_LOCAL_SERVER,IID_IGetStatus,(void **)&pGetStatus); if(SUCCEEDED(hr)) { try { _bstr_t str1 ; str1 = pGetStatus->GetBeat(); char* Text = _com_util::ConvertBSTRToString(str1); AfxMessageBox(Text); ::SysFreeString(str1); UINT CPU_Info = pGetStatus->Get_CPU(); int Memory_Info = pGetStatus->Get_Memory(); } catch(_com_error e) { AfxMessageBox(e.ErrorMessage(),MB_ICONSTOP); } }

                                  V Offline
                                  V Offline
                                  Vi2
                                  wrote on last edited by
                                  #16

                                  try
                                  {
                                  _bstr_t str1 ;
                                  str1 = pGetStatus->GetBeat();

                                  char* Text = str1;
                                  AfxMessageBox(Text);

                                  UINT CPU_Info = pGetStatus->Get_CPU();
                                  int Memory_Info = pGetStatus->Get_Memory();
                                  }

                                  With best wishes, Vita

                                  R 1 Reply Last reply
                                  0
                                  • R RevathiRamakumar

                                    Thanks for the reply Roger..I tried the way u suggested.. I unregistered the server ,built it again and then registered it..I also cleaned up the client and tried to built it again..HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method... :(

                                    R Offline
                                    R Offline
                                    Roger Stoltz
                                    wrote on last edited by
                                    #17

                                    RevathiRamakumar wrote:

                                    HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method...

                                    That's odd... If you're able to successfully create the server and get a valid pointer to the interface, I cannot see how you could get an access violation making the call. It feels like there's some kind of mismatch between the server, typelib and client. If you have changed from an IDispatch-derived interface to an IUnknown-derived, the virtual table the client tries to use may be out of sync. That's why I suggested that you should unregister all and rebuild from scratch. How is your interface declared in the IDL-file? It should be something like this:

                                    [
                                    object,
                                    uuid( xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ),
                                    oleautomation,
                                    helpstring( "IGetStatus interface" ),
                                    ]
                                    interface IGetStatus : IUnknown
                                    {
                                    HRESULT GetBeat( [out] BSTR* pbstrTheBeat );
                                    HRESULT GetCPU( [out] unsigned long* pulCpuLoad );
                                    HRESULT GetMemory( [out] unsigned long* pulMemory );
                                    };

                                    Also make sure in the client that the IGetStatus interface, declared in the complier generated header file, only contains QueryInterface(), AddRef(), Release(), GetBeat(), GetCPU() and GetMemory(). Try using one of the other interface functions since it's more straight forward with integer values and you don't have to worry about string obscurities. When you get that working you can continue with IGetStatus::GetBeat().

                                    "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                                    "High speed never compensates for wrong direction!" - unknown

                                    R 2 Replies Last reply
                                    0
                                    • R Roger Stoltz

                                      RevathiRamakumar wrote:

                                      HRESULT Of ::CoCreateInstance() returned 0 and the interface pointer points a valid address..But, again Access Denied while calling the server method...

                                      That's odd... If you're able to successfully create the server and get a valid pointer to the interface, I cannot see how you could get an access violation making the call. It feels like there's some kind of mismatch between the server, typelib and client. If you have changed from an IDispatch-derived interface to an IUnknown-derived, the virtual table the client tries to use may be out of sync. That's why I suggested that you should unregister all and rebuild from scratch. How is your interface declared in the IDL-file? It should be something like this:

                                      [
                                      object,
                                      uuid( xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ),
                                      oleautomation,
                                      helpstring( "IGetStatus interface" ),
                                      ]
                                      interface IGetStatus : IUnknown
                                      {
                                      HRESULT GetBeat( [out] BSTR* pbstrTheBeat );
                                      HRESULT GetCPU( [out] unsigned long* pulCpuLoad );
                                      HRESULT GetMemory( [out] unsigned long* pulMemory );
                                      };

                                      Also make sure in the client that the IGetStatus interface, declared in the complier generated header file, only contains QueryInterface(), AddRef(), Release(), GetBeat(), GetCPU() and GetMemory(). Try using one of the other interface functions since it's more straight forward with integer values and you don't have to worry about string obscurities. When you get that working you can continue with IGetStatus::GetBeat().

                                      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
                                      "High speed never compensates for wrong direction!" - unknown

                                      R Offline
                                      R Offline
                                      RevathiRamakumar
                                      wrote on last edited by
                                      #18

                                      Thanks for ur reply...When I tried calling AddRef() It worked fine... ULONG i = pGetStatus->AddRef();//i=2 But, when the other methods are being called, it gives me access denied error..K I'll keep trying ..Thank u...

                                      1 Reply Last reply
                                      0
                                      • V Vi2

                                        try
                                        {
                                        _bstr_t str1 ;
                                        str1 = pGetStatus->GetBeat();

                                        char* Text = str1;
                                        AfxMessageBox(Text);

                                        UINT CPU_Info = pGetStatus->Get_CPU();
                                        int Memory_Info = pGetStatus->Get_Memory();
                                        }

                                        With best wishes, Vita

                                        R Offline
                                        R Offline
                                        RevathiRamakumar
                                        wrote on last edited by
                                        #19

                                        Thank u....Ya I tried them but ,getting Access Denied Error..

                                        R 1 Reply Last reply
                                        0
                                        • R RevathiRamakumar

                                          Thank u....Ya I tried them but ,getting Access Denied Error..

                                          R Offline
                                          R Offline
                                          RevathiRamakumar
                                          wrote on last edited by
                                          #20

                                          Hi.. Now I could call the methods... I changed the Authentication level as NONE in the DCOM configuration... Its working fine.. Thank u ... :)

                                          modified on Wednesday, April 15, 2009 6:28 AM

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups