I was searching through MSDN pages. I've end up here;
http://msdn2.microsoft.com/en-us/library/aa390422.aspx
But when I tried to compile the code given below the page,
I get this error; - c:\program files\microsoft visual studio\vc98\include\comutil.h(101) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1786) Please choose the Technical Support command on the Visual C++
-
Help menu, or open the Technical Support help file for more informationError executing cl.exe.
-
dsa.exe - 1 error(s), 0 warning(s)
Any ideas?..
Thanks..
6 4131
Your build choked on line 101 of the header comutil.h. Something cause the compiler to be uable to parse the line.
It could be bad code preceding this include.
It could be a file with garbage characters in it.
Maybe you couild provide the code around this area.
Maybe you couild provide the code around this area.
As I said before, the page I was checking is this: http://msdn2.microsoft.com/en-us/library/aa390422.aspx
And the code, which I got the error is this: - #define _WIN32_DCOM
-
#include <iostream>
-
using namespace std;
-
#include <comdef.h>
-
#include <Wbemidl.h>
-
# pragma comment(lib, "wbemuuid.lib")
-
# pragma comment(lib, "credui.lib")
-
#include <wincred.h>
-
-
int main(int argc, char **argv)
-
{
-
HRESULT hres;
-
-
// Step 1: --------------------------------------------------
-
// Initialize COM. ------------------------------------------
-
-
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
-
if (FAILED(hres))
-
{
-
cout << "Failed to initialize COM library. Error code = 0x"
-
<< hex << hres << endl;
-
return 1; // Program has failed.
-
}
-
-
// Step 2: --------------------------------------------------
-
// Set general COM security levels --------------------------
-
// Note: If you are using Windows 2000, you need to specify -
-
// the default authentication credentials for a user by using
-
// a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
-
// parameter of CoInitializeSecurity ------------------------
-
-
hres = CoInitializeSecurity(
-
NULL,
-
-1, // COM authentication
-
NULL, // Authentication services
-
NULL, // Reserved
-
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
-
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
-
NULL, // Authentication info
-
EOAC_NONE, // Additional capabilities
-
NULL // Reserved
-
);
-
-
-
if (FAILED(hres))
-
{
-
cout << "Failed to initialize security. Error code = 0x"
-
<< hex << hres << endl;
-
CoUninitialize();
-
return 1; // Program has failed.
-
}
-
-
// Step 3: ---------------------------------------------------
-
// Obtain the initial locator to WMI -------------------------
-
-
IWbemLocator *pLoc = NULL;
-
-
hres = CoCreateInstance(
-
CLSID_WbemLocator,
-
0,
-
CLSCTX_INPROC_SERVER,
-
IID_IWbemLocator, (LPVOID *) &pLoc);
-
-
if (FAILED(hres))
-
{
-
cout << "Failed to create IWbemLocator object."
-
<< " Err code = 0x"
-
<< hex << hres << endl;
-
CoUninitialize();
-
return 1; // Program has failed.
-
}
-
-
// Step 4: -----------------------------------------------------
-
// Connect to WMI through the IWbemLocator::ConnectServer method
-
-
IWbemServices *pSvc = NULL;
-
-
// Get the user name and password for the remote computer
-
CREDUI_INFO cui;
-
TCHAR pszName[CREDUI_MAX_USERNAME_LENGTH+1];
-
TCHAR pszPwd[CREDUI_MAX_PASSWORD_LENGTH+1];
-
BOOL fSave;
-
DWORD dwErr;
-
-
cui.cbSize = sizeof(CREDUI_INFO);
-
cui.hwndParent = NULL;
-
// Ensure that MessageText and CaptionText identify
-
// what credentials to use and which application requires them.
-
cui.pszMessageText = TEXT("Remote computer account information");
-
cui.pszCaptionText = TEXT("Enter Account Information");
-
cui.hbmBanner = NULL;
-
fSave = FALSE;
-
-
dwErr = CredUIPromptForCredentials(
-
&cui, // CREDUI_INFO structure
-
TEXT(""), // Target for credentials
-
NULL, // Reserved
-
0, // Reason
-
pszName, // User name
-
CREDUI_MAX_USERNAME_LENGTH+1, // Max number for user name
-
pszPwd, // Password
-
CREDUI_MAX_PASSWORD_LENGTH+1, // Max number for password
-
&fSave, // State of save check box
-
CREDUI_FLAGS_GENERIC_CREDENTIALS | // flags
-
CREDUI_FLAGS_ALWAYS_SHOW_UI |
-
CREDUI_FLAGS_DO_NOT_PERSIST);
-
-
if(dwErr)
-
{
-
cout << "Did not get credentials." << endl;
-
pLoc->Release();
-
CoUninitialize();
-
return 1;
-
}
-
-
// Connect to the remote root\cimv2 namespace
-
// and obtain pointer pSvc to make IWbemServices calls.
-
//---------------------------------------------------------
-
// change the computerName and domain
-
// strings below to the full computer name and domain
-
// of the remote computer
-
-
hres = pLoc->ConnectServer(
-
_bstr_t(L"\\\\computerName\\root\\cimv2"),
-
_bstr_t(pszName), // User name
-
_bstr_t(pszPwd), // User password
-
_bstr_t(L"MS_409"), // Locale
-
NULL, // Security flags
-
_bstr_t(L"ntlmdomain:domain"), // Authority
-
0, // Context object
-
&pSvc // IWbemServices proxy
-
);
-
-
// When you have finished using the credentials,
-
// erase them from memory.
-
SecureZeroMemory(pszName, sizeof(pszName));
-
SecureZeroMemory(pszPwd, sizeof(pszPwd));
-
-
if (FAILED(hres))
-
{
-
cout << "Could not connect. Error code = 0x"
-
<< hex << hres << endl;
-
pLoc->Release();
-
CoUninitialize();
-
return 1; // Program has failed.
-
}
-
-
cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
-
-
-
// Step 5: --------------------------------------------------
-
// Set security levels on a WMI connection ------------------
-
-
hres = CoSetProxyBlanket(
-
pSvc, // Indicates the proxy to set
-
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
-
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
-
NULL, // Server principal name
-
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
-
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
-
NULL, // client identity
-
EOAC_NONE // proxy capabilities
-
);
-
-
if (FAILED(hres))
-
{
-
cout << "Could not set proxy blanket. Error code = 0x"
-
<< hex << hres << endl;
-
pSvc->Release();
-
pLoc->Release();
-
CoUninitialize();
-
return 1; // Program has failed.
-
}
-
-
// Step 6: --------------------------------------------------
-
// Use the IWbemServices pointer to make requests of WMI ----
-
-
// For example, get the name of the operating system
-
IEnumWbemClassObject* pEnumerator = NULL;
-
hres = pSvc->ExecQuery(
-
bstr_t("WQL"),
-
bstr_t("Select * from Win32_OperatingSystem"),
-
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
-
NULL,
-
&pEnumerator);
-
-
if (FAILED(hres))
-
{
-
cout << "Query for operating system name failed."
-
<< " Error code = 0x"
-
<< hex << hres << endl;
-
pSvc->Release();
-
pLoc->Release();
-
CoUninitialize();
-
return 1; // Program has failed.
-
}
-
-
// Step 7: -------------------------------------------------
-
// Get the data from the query in step 6 -------------------
-
-
IWbemClassObject *pclsObj;
-
ULONG uReturn = 0;
-
-
while (pEnumerator)
-
{
-
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
-
&pclsObj, &uReturn);
-
-
if(0 == uReturn)
-
{
-
break;
-
}
-
-
VARIANT vtProp;
-
-
// Get the value of the Name property
-
hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
-
wcout << " OS Name : " << vtProp.bstrVal << endl;
-
-
// Get the value of the FreePhysicalMemory property
-
hr = pclsObj->Get(L"FreePhysicalMemory",
-
0, &vtProp, 0, 0);
-
wcout << " Free physical memory (in kilobytes): "
-
<< vtProp.uintVal << endl;
-
VariantClear(&vtProp);
-
}
-
-
// Cleanup
-
// ========
-
-
pSvc->Release();
-
pLoc->Release();
-
pEnumerator->Release();
-
pclsObj->Release();
-
CoUninitialize();
-
-
return 0; // Program successfully completed.
-
-
}
Thanks again..
I just compiled and linked your code with no warnings and no errors using Visual Studio.NET 2005 and a Win32 Console Application project.
What compiler and project type are you using??
I just compiled and linked your code with no warnings and no errors using Visual Studio.NET 2005 and a Win32 Console Application project.
What compiler and project type are you using??
I'm using Microsoft Visual Studio 6.0 and Win32 Console Application project.
I'm using Microsoft Visual Studio 6.0 and Win32 Console Application project.
Even with all service packs applied, VC 6.0 is three releases in the past.
A lot of bugs were not backfitted into VC 6.0 but were only carried forward.
Time to get the current version of the compiler.
Even with all service packs applied, VC 6.0 is three releases in the past.
A lot of bugs were not backfitted into VC 6.0 but were only carried forward.
Time to get the current version of the compiler.
Thanks for your interest, I'll get it..
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Watson |
last post by:
I recently had to reinstall visual basic 6.0. I also reinstalled
the msdn files that came with vb6.
When I need to search for an item in help, I type the keyword
into the text box on the index...
|
by: AC |
last post by:
I installed msdn and help is still looking for the cd..
how do I get it to look to the installed directory?
thanks.
|
by: Rafael Lopez |
last post by:
How can i configure a computer to use the MSDN HELP of Visual Studio .NET
that resides in other computer?
Thanks.
My clients that not have disk space enough to support the MSDN HELP
installed...
|
by: TomB |
last post by:
I'm using VB.net standard that came with the book "Visual Basic .net
step by step" MS Press version 2003. I found out I was missing the
MSDN library from book. I contacted MS Press who send them....
|
by: DM |
last post by:
This example copied from MSDN help does not work on any of my PC's. When
the dialog opens, itdisplays a blank page. I'm trying to create a dialog
that calls a function in the page that opened it...
|
by: PlumeProg |
last post by:
Hello, I can't find a way to bind a dataset at runtime as
a source for my report source.
I looked into msdn and found some sample :
ms-...
|
by: Jon Slaughter |
last post by:
When I used to program in windows(back in the days of win95/98) the help
system was very good. You could find out all th details of just about
anything with usually decent explinations of what does...
|
by: John Dalberg |
last post by:
Is there a way to convert a section of the MSDN .NET help to pdf format? I
would like to read these on my eReader.
John Dalberg
|
by: umeshkumar |
last post by:
HIi,
Is there any one who can help me with msdn file, the file that i got is not iastalling and is there any free download avaliable on net of same file ?
|
by: Trupti salvi |
last post by:
I want to download the MSDN help file for visual basic6.0.please send me the sites from where i can download these MSDN files
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |