WMI errors in VC7
-
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!
-
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!
Missing header? VC7 using different set of headers if you are aware of it. Sonork 100.41263:Anthony_Yio Life is about experiencing ...
-
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!
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!
-
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!
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 yourstdafx.h
from your VC6 project.objbase.h
is included byole2.h
in the Platform SDK that ships with Visual Studio .NET 2003. However,ole2.h
is not included if you defineNOGDI
unless you also defineINC_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 -
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 yourstdafx.h
from your VC6 project.objbase.h
is included byole2.h
in the Platform SDK that ships with Visual Studio .NET 2003. However,ole2.h
is not included if you defineNOGDI
unless you also defineINC_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 MaunderIm 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!
-
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!
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 whyCoCreateInstance
would still be undefined if you've included bothwindows.h
andobjbase.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 towbemuuid.lib
. Stability. What an interesting concept. -- Chris Maunder -
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 whyCoCreateInstance
would still be undefined if you've included bothwindows.h
andobjbase.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 towbemuuid.lib
. Stability. What an interesting concept. -- Chris MaunderAdding wbemuuid.lib sorted it, thanks a million, your a star!:-D We have a mathematician, a different kind of mathematician, and a statistician!