473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

MSDN Help

stormrider
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;
Expand|Select|Wrap|Line Numbers
  1. 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++
  2. Help menu, or open the Technical Support help file for more informationError executing cl.exe.
  3. dsa.exe - 1 error(s), 0 warning(s)
Any ideas?..
Thanks..
Sep 8 '07 #1
6 4131
weaknessforcats
9,208 Expert Mod 8TB
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.
Sep 8 '07 #2
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:
Expand|Select|Wrap|Line Numbers
  1. #define _WIN32_DCOM
  2. #include <iostream>
  3. using namespace std;
  4. #include <comdef.h>
  5. #include <Wbemidl.h>
  6. # pragma comment(lib, "wbemuuid.lib")
  7. # pragma comment(lib, "credui.lib")
  8. #include <wincred.h>
  9.  
  10. int main(int argc, char **argv)
  11. {
  12.     HRESULT hres;
  13.  
  14.     // Step 1: --------------------------------------------------
  15.     // Initialize COM. ------------------------------------------
  16.  
  17.     hres =  CoInitializeEx(0, COINIT_MULTITHREADED); 
  18.     if (FAILED(hres))
  19.     {
  20.         cout << "Failed to initialize COM library. Error code = 0x" 
  21.             << hex << hres << endl;
  22.         return 1;                  // Program has failed.
  23.     }
  24.  
  25.     // Step 2: --------------------------------------------------
  26.     // Set general COM security levels --------------------------
  27.     // Note: If you are using Windows 2000, you need to specify -
  28.     // the default authentication credentials for a user by using
  29.     // a SOLE_AUTHENTICATION_LIST structure in the pAuthList ----
  30.     // parameter of CoInitializeSecurity ------------------------
  31.  
  32.     hres =  CoInitializeSecurity(
  33.         NULL, 
  34.         -1,                          // COM authentication
  35.         NULL,                        // Authentication services
  36.         NULL,                        // Reserved
  37.         RPC_C_AUTHN_LEVEL_DEFAULT,   // Default authentication 
  38.         RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation  
  39.         NULL,                        // Authentication info
  40.         EOAC_NONE,                   // Additional capabilities 
  41.         NULL                         // Reserved
  42.         );
  43.  
  44.  
  45.     if (FAILED(hres))
  46.     {
  47.         cout << "Failed to initialize security. Error code = 0x" 
  48.             << hex << hres << endl;
  49.         CoUninitialize();
  50.         return 1;                    // Program has failed.
  51.     }
  52.  
  53.     // Step 3: ---------------------------------------------------
  54.     // Obtain the initial locator to WMI -------------------------
  55.  
  56.     IWbemLocator *pLoc = NULL;
  57.  
  58.     hres = CoCreateInstance(
  59.         CLSID_WbemLocator,             
  60.         0, 
  61.         CLSCTX_INPROC_SERVER, 
  62.         IID_IWbemLocator, (LPVOID *) &pLoc);
  63.  
  64.     if (FAILED(hres))
  65.     {
  66.         cout << "Failed to create IWbemLocator object."
  67.             << " Err code = 0x"
  68.             << hex << hres << endl;
  69.         CoUninitialize();
  70.         return 1;                 // Program has failed.
  71.     }
  72.  
  73.     // Step 4: -----------------------------------------------------
  74.     // Connect to WMI through the IWbemLocator::ConnectServer method
  75.  
  76.     IWbemServices *pSvc = NULL;
  77.  
  78.     // Get the user name and password for the remote computer
  79.     CREDUI_INFO cui;
  80.     TCHAR pszName[CREDUI_MAX_USERNAME_LENGTH+1];
  81.     TCHAR pszPwd[CREDUI_MAX_PASSWORD_LENGTH+1];
  82.     BOOL fSave;
  83.     DWORD dwErr;
  84.  
  85.     cui.cbSize = sizeof(CREDUI_INFO);
  86.     cui.hwndParent = NULL;
  87.     // Ensure that MessageText and CaptionText identify
  88.     // what credentials to use and which application requires them.
  89.     cui.pszMessageText = TEXT("Remote computer account information");
  90.     cui.pszCaptionText = TEXT("Enter Account Information");
  91.     cui.hbmBanner = NULL;
  92.     fSave = FALSE;
  93.  
  94.     dwErr = CredUIPromptForCredentials( 
  95.         &cui,                             // CREDUI_INFO structure
  96.         TEXT(""),                         // Target for credentials
  97.         NULL,                             // Reserved
  98.         0,                                // Reason
  99.         pszName,                          // User name
  100.         CREDUI_MAX_USERNAME_LENGTH+1,     // Max number for user name
  101.         pszPwd,                           // Password
  102.         CREDUI_MAX_PASSWORD_LENGTH+1,     // Max number for password
  103.         &fSave,                           // State of save check box
  104.         CREDUI_FLAGS_GENERIC_CREDENTIALS |  // flags
  105.         CREDUI_FLAGS_ALWAYS_SHOW_UI |
  106.         CREDUI_FLAGS_DO_NOT_PERSIST);  
  107.  
  108.     if(dwErr)
  109.     {
  110.         cout << "Did not get credentials." << endl;
  111.         pLoc->Release();     
  112.         CoUninitialize();
  113.         return 1;      
  114.     }
  115.  
  116.     // Connect to the remote root\cimv2 namespace
  117.     // and obtain pointer pSvc to make IWbemServices calls.
  118.     //---------------------------------------------------------
  119.     // change the computerName and domain 
  120.     // strings below to the full computer name and domain 
  121.     // of the remote computer
  122.  
  123.     hres = pLoc->ConnectServer(
  124.         _bstr_t(L"\\\\computerName\\root\\cimv2"),
  125.         _bstr_t(pszName),                 // User name
  126.         _bstr_t(pszPwd),                  // User password
  127.         _bstr_t(L"MS_409"),               // Locale             
  128.         NULL,                             // Security flags
  129.         _bstr_t(L"ntlmdomain:domain"),    // Authority        
  130.         0,                                // Context object 
  131.         &pSvc                             // IWbemServices proxy
  132.         );
  133.  
  134.     // When you have finished using the credentials,
  135.     // erase them from memory.
  136.     SecureZeroMemory(pszName, sizeof(pszName));
  137.     SecureZeroMemory(pszPwd, sizeof(pszPwd));
  138.  
  139.     if (FAILED(hres))
  140.     {
  141.         cout << "Could not connect. Error code = 0x" 
  142.              << hex << hres << endl;
  143.         pLoc->Release();     
  144.         CoUninitialize();
  145.         return 1;                // Program has failed.
  146.     }
  147.  
  148.     cout << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
  149.  
  150.  
  151.     // Step 5: --------------------------------------------------
  152.     // Set security levels on a WMI connection ------------------
  153.  
  154.     hres = CoSetProxyBlanket(
  155.        pSvc,                        // Indicates the proxy to set
  156.        RPC_C_AUTHN_WINNT,           // RPC_C_AUTHN_xxx
  157.        RPC_C_AUTHZ_NONE,            // RPC_C_AUTHZ_xxx
  158.        NULL,                        // Server principal name 
  159.        RPC_C_AUTHN_LEVEL_CALL,      // RPC_C_AUTHN_LEVEL_xxx 
  160.        RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
  161.        NULL,                        // client identity
  162.        EOAC_NONE                    // proxy capabilities 
  163.     );
  164.  
  165.     if (FAILED(hres))
  166.     {
  167.         cout << "Could not set proxy blanket. Error code = 0x" 
  168.             << hex << hres << endl;
  169.         pSvc->Release();
  170.         pLoc->Release();     
  171.         CoUninitialize();
  172.         return 1;               // Program has failed.
  173.     }
  174.  
  175.     // Step 6: --------------------------------------------------
  176.     // Use the IWbemServices pointer to make requests of WMI ----
  177.  
  178.     // For example, get the name of the operating system
  179.     IEnumWbemClassObject* pEnumerator = NULL;
  180.     hres = pSvc->ExecQuery(
  181.         bstr_t("WQL"), 
  182.         bstr_t("Select * from Win32_OperatingSystem"),
  183.         WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 
  184.         NULL,
  185.         &pEnumerator);
  186.  
  187.     if (FAILED(hres))
  188.     {
  189.         cout << "Query for operating system name failed."
  190.             << " Error code = 0x" 
  191.             << hex << hres << endl;
  192.         pSvc->Release();
  193.         pLoc->Release();
  194.         CoUninitialize();
  195.         return 1;               // Program has failed.
  196.     }
  197.  
  198.     // Step 7: -------------------------------------------------
  199.     // Get the data from the query in step 6 -------------------
  200.  
  201.     IWbemClassObject *pclsObj;
  202.     ULONG uReturn = 0;
  203.  
  204.     while (pEnumerator)
  205.     {
  206.         HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, 
  207.             &pclsObj, &uReturn);
  208.  
  209.         if(0 == uReturn)
  210.         {
  211.             break;
  212.         }
  213.  
  214.         VARIANT vtProp;
  215.  
  216.         // Get the value of the Name property
  217.         hr = pclsObj->Get(L"Name", 0, &vtProp, 0, 0);
  218.         wcout << " OS Name : " << vtProp.bstrVal << endl;
  219.  
  220.         // Get the value of the FreePhysicalMemory property
  221.         hr = pclsObj->Get(L"FreePhysicalMemory",
  222.             0, &vtProp, 0, 0);
  223.         wcout << " Free physical memory (in kilobytes): "
  224.             << vtProp.uintVal << endl;
  225.         VariantClear(&vtProp);
  226.     }
  227.  
  228.     // Cleanup
  229.     // ========
  230.  
  231.     pSvc->Release();
  232.     pLoc->Release();
  233.     pEnumerator->Release();
  234.     pclsObj->Release();
  235.     CoUninitialize();
  236.  
  237.     return 0;   // Program successfully completed.
  238.  
  239. }
Thanks again..
Sep 8 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
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??
Sep 9 '07 #4
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.
Sep 10 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
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.
Sep 11 '07 #6
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..
Sep 12 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
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...
1
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.
0
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...
0
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....
0
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...
1
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-...
6
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...
6
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
0
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 ?
0
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
0
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
1
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...
0
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...
0
marktang
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,...
0
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.