Tag Archives: vc++

VC + + compiler can not find the header file and rebuild failure

1. The header file cannot be found

If the associated path of the header file is not set properly, you need to add both the root directory and the subdirectory to the additional header file directory. For example, if there are two header files in the root directory and the subdirectories sub1 and sub2 that need to be referenced elsewhere, you should add the header file path to the additional package directory in this way:

$(SolutionDir)root

$(SolutionDir)root\sub1

$(SolutionDir)root\sub2

2. It is successful to compile a library alone, but rebuild prompts that the related projects fail to compile

In this case, the lazy relationship between project references is not set well. You should right-click on the solution, – gt; common properties – & gt; project dependencies, and set the lazy relationship between project references without omission. In this way, the rebuild will succeed on the top-level project. At the same time, the compilation of dynamic library and other similar problems can also be solved.

 

 

 

IntelliSense in VC + + 2010: unable to open source file “StdAfx. H”

Refer to http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/efdf4ae8-437d-4a7f-8cf5-b895257da2bd
 
Problems such as unable to find files can be solved with this method, is the path problem. Similar problems may occur when a VC ++2008 project is transferred to VC ++2010.
 
Solution:
Add $(projectDir) to the Project Properties = Configuration Properties = C/C++ = General = Additional Includes directory
See below

VC + + COM programming error of 0xc0000005: access conflict when reading location 0xfeefef6

Calling COM+ gives you the desired result and returns an error after the last return 0 sentence.

error location in comip.h

void _Release() throw()

{

if (m_pInterface! = NULL) {

m_pInterface – & gt; Release(); // Error reported here

}

}
When I encounter this problem myself, I use m_pInterface->; Release(); Comment out the program no longer reports an error.
Some other ways online:
1.m_pInterface-> Release () into m_pInterface = NULL from http://topic.csdn.net/u/20091120/16/8a9c8d91-9a39-416b-8d8d-8c2cd2a71d3e.html
2. In the program implementation: PTR ->; Release(); To PTR. Release (); From http://topic.csdn.net/u/20091120/16/8a9c8d91-9a39-416b-8d8d-8c2cd2a71d3e.html
3. One statement is that it is a matter of scope. I don’t know much about it. See: http://stackoverflow.com/questions/2653797/why-does-couninitialize-cause-an-error-on-exit
This method has been tried, but it also works. See the following instructions for details.

I’m working on a C++ application to read some data from an Excel file. I’ve got it working, but I’m confused about one part. Here’s the code (simplified to read only the first cell).

//Mostly copied from http://www.codeproject.com/KB/wtl/WTLExcel.aspx 
 
#import "c:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL" 
#import "c:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" 
#import "C:\Program Files\Microsoft Office\Office11\excel.exe" rename ("DialogBox","ExcelDialogBox") rename("RGB","ExcelRGB") rename("CopyFile", "ExcelCopyFile") rename("ReplaceText", "ExcelReplaceText") exclude("IFont", "IPicture") 
 
_variant_t varOption((long) DISP_E_PARAMNOTFOUND, VT_ERROR); 
 
int _tmain(int argc, _TCHAR* argv[]) 
{ 
    DWORD dwCoInit = 0; 
    CoInitializeEx(NULL, dwCoInit); 
    Excel::_ApplicationPtr pExcel;     
    pExcel.CreateInstance(_T("Excel.Application")); 
    Excel::_WorkbookPtr pBook; 
    pBook = pExcel->Workbooks->Open("c:\\test.xls", varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption); 
    Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[1]; 
    Excel::RangePtr pRange = pSheet->GetRange(_bstr_t(_T("A1"))); 
    _variant_t vItem = pRange->Value2; 
    printf(_bstr_t(vItem.bstrVal));     
    pBook->Close(VARIANT_FALSE); 
    pExcel->Quit(); 
    //CoUninitialize(); 
    return 0; 
} 

I had to comment out the call to CoUninitialize for the program to work. When CoUninitialize is uncommented, I get an access violation in the _Release function in comip.h on program exit.
Here’s the code from comip. h, for what it’s worth.

void _Release() throw() 
{ 
    if (m_pInterface != NULL) { 
        m_pInterface->Release(); 
    } 
} 

I’m not very experienced with COM programming, so there’s probably something obvious I’m missing.

    Why does the call to CoUninitialize cause an exception? What are the consequences of not calling CoUninitialize? Am I doing something completely wrong here?

ANSWER!

The problem you are having is one of scope. The short answer is to move the CoInit and CoUninit into an outer scope from the Ptrs. For example:

//Mostly copied from http://www.codeproject.com/KB/wtl/WTLExcel.aspx 
 
#import "c:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL" 
#import "c:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" 
#import "C:\Program Files\Microsoft Office\Office11\excel.exe" rename ("DialogBox","ExcelDialogBox") rename("RGB","ExcelRGB") rename("CopyFile", "ExcelCopyFile") rename("ReplaceText", "ExcelReplaceText") exclude("IFont", "IPicture") 
 
_variant_t varOption((long) DISP_E_PARAMNOTFOUND, VT_ERROR); 
 
int _tmain(int argc, _TCHAR* argv[]) 
{ 
    DWORD dwCoInit = 0; 
    CoInitializeEx(NULL, dwCoInit); 
    { 
        Excel::_ApplicationPtr pExcel;     
        pExcel.CreateInstance(_T("Excel.Application")); 
        Excel::_WorkbookPtr pBook; 
        pBook = pExcel->Workbooks->Open("c:\\test.xls", varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption); 
        Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[1]; 
        Excel::RangePtr pRange = pSheet->GetRange(_bstr_t(_T("A1"))); 
        _variant_t vItem = pRange->Value2; 
        printf(_bstr_t(vItem.bstrVal));     
        pBook->Close(VARIANT_FALSE); 
        pExcel->Quit(); 
    } 
    CoUninitialize(); 
    return 0; 
} 

The longer answer is that the Ptrs destructors (which calls Release) are being called on exit from main. This is after CoUnit which, basically, shuts down the communication channel between your app and the COM object.
What are the consequences of not calling CoUnit?For short lived in-process COM servers, there really isn’t any negative consequence.

error: Unable to find vcvarsall.bat terms of settlement

I got an error installing Impyla on Windows

Then I searched some information on the Internet, some said to install WHL files directly (failed), some said to install vs files (too big), some said to install a separate development tool set (vc++), the following I use is to install vc++, its download site and instructions are as follows:
https://blogs.msdn.microsoft.com/vcblog/2015/11/02/announcing-visual-c-build-tools-2015-standalone-c-tools-for-build-environments/
After entering the url, click the url in the red box

You can choose the old version, I will not screenshot demonstration here, directly give a 2015 version of the download address
https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/
Select the one in the red box, and then download:

Because I was win10, and I chose

If you reported this error during the installation process: Error code 15605
So you need over the wall to download.
After downloading, reinstall Impyla, success!