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. C / C++ / MFC
  4. WMI errors in VC7

WMI errors in VC7

Scheduled Pinned Locked Moved C / C++ / MFC
help
7 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
    roadragedave
    wrote on last edited by
    #1

    I dont understand why Im getting this problem, because the code works fine in VC6, but when i use VC7, i get a whole range of errors, Im trying to connect to WMI, so I go through the usual steps, 1: CoInitializeSecurity, 2: CoCreateInstance, 3: ConnectServer, 4: CoSetProxyBlanket. However when I build I get: error C3861: 'CoInitializeSecurity': identifier not found, even with argument-dependent lookup. & error C3861: 'CoSetProxyBlanket': identifier not found, even with argument-dependent lookup are both these functions using different libs or headers from the other two, Ive looked at the MSDN, and the FAQ, but I cant make sense of either. Im also getting some wierd errors in my header file: error C2143: syntax error : missing ';' before '*' error C2501: 'WmiWrapper::IWbemServices' : missing storage-class or type specifiers Im possitive there is no syntax error like missing ';' or anything like that. We have a mathematician, a different kind of mathematician, and a statistician!

    A R M 3 Replies Last reply
    0
    • R roadragedave

      I dont understand why Im getting this problem, because the code works fine in VC6, but when i use VC7, i get a whole range of errors, Im trying to connect to WMI, so I go through the usual steps, 1: CoInitializeSecurity, 2: CoCreateInstance, 3: ConnectServer, 4: CoSetProxyBlanket. However when I build I get: error C3861: 'CoInitializeSecurity': identifier not found, even with argument-dependent lookup. & error C3861: 'CoSetProxyBlanket': identifier not found, even with argument-dependent lookup are both these functions using different libs or headers from the other two, Ive looked at the MSDN, and the FAQ, but I cant make sense of either. Im also getting some wierd errors in my header file: error C2143: syntax error : missing ';' before '*' error C2501: 'WmiWrapper::IWbemServices' : missing storage-class or type specifiers Im possitive there is no syntax error like missing ';' or anything like that. We have a mathematician, a different kind of mathematician, and a statistician!

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      Missing header? VC7 using different set of headers if you are aware of it. Sonork 100.41263:Anthony_Yio Life is about experiencing ...

      1 Reply Last reply
      0
      • R roadragedave

        I dont understand why Im getting this problem, because the code works fine in VC6, but when i use VC7, i get a whole range of errors, Im trying to connect to WMI, so I go through the usual steps, 1: CoInitializeSecurity, 2: CoCreateInstance, 3: ConnectServer, 4: CoSetProxyBlanket. However when I build I get: error C3861: 'CoInitializeSecurity': identifier not found, even with argument-dependent lookup. & error C3861: 'CoSetProxyBlanket': identifier not found, even with argument-dependent lookup are both these functions using different libs or headers from the other two, Ive looked at the MSDN, and the FAQ, but I cant make sense of either. Im also getting some wierd errors in my header file: error C2143: syntax error : missing ';' before '*' error C2501: 'WmiWrapper::IWbemServices' : missing storage-class or type specifiers Im possitive there is no syntax error like missing ';' or anything like that. We have a mathematician, a different kind of mathematician, and a statistician!

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

        I got rid of the small weird errors in the header file but if anyone knows about header files that are used in VC7 that are not used in VC6, as regards WMI, then please let me know. The headers im using so far are: #include string.h #include wbemidl.h #include windows.h #include objbase.h #include wbemcli.h #include comdef.h #include tchar.h #include stdio.h Some of these may even be sitting there doing nothing, According to the MSDN both functions that are giving me problems (CoInitializeSecurity & CoSetProxyBlanket) are in "objbase.h" and use "ole32.lib", and I have referenced both.:confused: We have a mathematician, a different kind of mathematician, and a statistician!

        1 Reply Last reply
        0
        • R roadragedave

          I dont understand why Im getting this problem, because the code works fine in VC6, but when i use VC7, i get a whole range of errors, Im trying to connect to WMI, so I go through the usual steps, 1: CoInitializeSecurity, 2: CoCreateInstance, 3: ConnectServer, 4: CoSetProxyBlanket. However when I build I get: error C3861: 'CoInitializeSecurity': identifier not found, even with argument-dependent lookup. & error C3861: 'CoSetProxyBlanket': identifier not found, even with argument-dependent lookup are both these functions using different libs or headers from the other two, Ive looked at the MSDN, and the FAQ, but I cant make sense of either. Im also getting some wierd errors in my header file: error C2143: syntax error : missing ';' before '*' error C2501: 'WmiWrapper::IWbemServices' : missing storage-class or type specifiers Im possitive there is no syntax error like missing ';' or anything like that. We have a mathematician, a different kind of mathematician, and a statistician!

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          You should be using #include <windows.h> for any Windows features, including COM. It needs to appear before any other Windows-related includes. windows.h includes a whole load of other include files; you can speed up compiles quite a bit by using pre-compiled headers. It may be that you haven't copied your stdafx.h from your VC6 project. objbase.h is included by ole2.h in the Platform SDK that ships with Visual Studio .NET 2003. However, ole2.h is not included if you define NOGDI unless you also define INC_OLE2. The C2143 error often occurs if a type isn't declared; the compiler assumes you were trying to define a variable with that name instead. The '*' is then illegal at that position, so it assumes a missing semicolon. Stability. What an interesting concept. -- Chris Maunder

          R 1 Reply Last reply
          0
          • M Mike Dimmick

            You should be using #include <windows.h> for any Windows features, including COM. It needs to appear before any other Windows-related includes. windows.h includes a whole load of other include files; you can speed up compiles quite a bit by using pre-compiled headers. It may be that you haven't copied your stdafx.h from your VC6 project. objbase.h is included by ole2.h in the Platform SDK that ships with Visual Studio .NET 2003. However, ole2.h is not included if you define NOGDI unless you also define INC_OLE2. The C2143 error often occurs if a type isn't declared; the compiler assumes you were trying to define a variable with that name instead. The '*' is then illegal at that position, so it assumes a missing semicolon. Stability. What an interesting concept. -- Chris Maunder

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

            Im already using #include <windows.h> and if I use precompiled headers then I get: fatal error C1010: unexpected end of file while looking for precompiled header directive. and the advice for this was "not to use precompiled headers" which gave me the problems I have now, Also, What can I do to get rid of: error LNK2001: unresolved external symbol _CLSID_WbemAdministrativeLocator _CLSID_WbemAdministrativeLocator should be a default value in the function CoCreateInstance. The code used looks like: hRes = CoCreateInstance (CLSID_WbemAdministrativeLocator, NULL , CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER , IID_IUnknown , ( void ** ) & IWbemLoc); I have also tried: hRes = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER,IID_IWbemLocator, (LPVOID *)&m_pIWbemLocator); and I get the same link error with both CLSID_WbemLocator & IID_IWbemLocator We have a mathematician, a different kind of mathematician, and a statistician!

            M 1 Reply Last reply
            0
            • R roadragedave

              Im already using #include <windows.h> and if I use precompiled headers then I get: fatal error C1010: unexpected end of file while looking for precompiled header directive. and the advice for this was "not to use precompiled headers" which gave me the problems I have now, Also, What can I do to get rid of: error LNK2001: unresolved external symbol _CLSID_WbemAdministrativeLocator _CLSID_WbemAdministrativeLocator should be a default value in the function CoCreateInstance. The code used looks like: hRes = CoCreateInstance (CLSID_WbemAdministrativeLocator, NULL , CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER , IID_IUnknown , ( void ** ) & IWbemLoc); I have also tried: hRes = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER,IID_IWbemLocator, (LPVOID *)&m_pIWbemLocator); and I get the same link error with both CLSID_WbemLocator & IID_IWbemLocator We have a mathematician, a different kind of mathematician, and a statistician!

              M Offline
              M Offline
              Mike Dimmick
              wrote on last edited by
              #6

              OK, if you decide to use precompiled headers, you need to either #include your precompiled header file in each source file, use a #pragma hdrstop directive, or disable pre-compiled headers for that file (in which case you should include any headers that you need for that source file). I can't see why CoCreateInstance would still be undefined if you've included both windows.h and objbase.h. Have you defined _OBJBASE_H_ somewhere? You could try using the /showIncludes option to the compiler to show which files are actually being included. I'm not sure if this option was available in VS.NET 2002. If objbase.h is definitely being included, try using the /P option (with /C to preserve comments) to generate a pre-processed output and check whether the declarations are being output. As for your other problem, you need to provide a definition as well as a declaration for your GUIDs. For WMI, you can simply link to wbemuuid.lib. Stability. What an interesting concept. -- Chris Maunder

              R 1 Reply Last reply
              0
              • M Mike Dimmick

                OK, if you decide to use precompiled headers, you need to either #include your precompiled header file in each source file, use a #pragma hdrstop directive, or disable pre-compiled headers for that file (in which case you should include any headers that you need for that source file). I can't see why CoCreateInstance would still be undefined if you've included both windows.h and objbase.h. Have you defined _OBJBASE_H_ somewhere? You could try using the /showIncludes option to the compiler to show which files are actually being included. I'm not sure if this option was available in VS.NET 2002. If objbase.h is definitely being included, try using the /P option (with /C to preserve comments) to generate a pre-processed output and check whether the declarations are being output. As for your other problem, you need to provide a definition as well as a declaration for your GUIDs. For WMI, you can simply link to wbemuuid.lib. Stability. What an interesting concept. -- Chris Maunder

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

                Adding wbemuuid.lib sorted it, thanks a million, your a star!:-D We have a mathematician, a different kind of mathematician, and a statistician!

                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