How to install and deploy the Crystal Report in VC ++

Source: Internet
Author: User

Recently, due to the need to use Crystal Reports, the environment is vs2008. Due to the uneven information on the Internet, and most of them have not been tested by themselves, the road used

 

. However, we finally solved the problem and shared it with you.

 

1. Use of Crystal Reports

 . However, you must note that the installation and running of these two versions must be at least. NET 2.0 or later.

1. Import the dynamic link library used by the crystal Report: Modify the file path according to the actual situation.

# Import "C: // program files // Business Objects // common // 2.8 // bin // craxddrt. DLL "no_namespace Rename (" findtext "," findmytext ") Rename (" enumfontfamilies "," myenumfontfamilies ") <br/> # include" Table/crystalreportviewer10.h"

2. Define interface pointer Variables

Iapplicationptr m_application; <br/> ireportptr m_report; </P> <p> ccrystalreportviewer10 m_view; // control variable of the Crystal Report </P> <p>

3. Specific implementation steps

It can be written in oninitdialog,

Try <br/> {</P> <p> hresult hR = m_application. createinstance (_ uuidof (Application); <br/> If (succeeded (HR )) <br/>{</P> <p> // open the crystal report <br/> m_report = m_application-> openreport (_ bstr_t (strdir )); <br/> If (m_report = NULL) <br/>{< br/> afxmessagebox (_ T ("An error occurred while opening the crystal report! /N. Check whether the report exists! /N "); <br/> m_application. release (); <br/> return false; <br/>}</P> <p> m_view.setreportsource (m_report); <br/> m_view.setdisplaybackgroundedge (true ); <br/> m_view.setdisplaytoolbar (false); <br/> m_view.setenablegrouptree (false); <br/> m_view.setenableexportbutton (true); <br/> m_view.setenabletoolbar (false ); <br/> m_view.setenablezoomcontrol (true); </P> <p> m_view.refresh (); </P> <p> m_view.viewreport (); // preview. </P> <p> getclientrect (& m_rect); </P> <p >}< br/> catch (_ com_error & E) <br/>{< br/> afxmessagebox (E. description (); <br/> return false; <br/>}< br/>

 

Now, the crystal report can be used.

Ii. installation and deployment

This is actually a troublesome part. I use vs2008 and need to be deployed in a completely new environment. occount exists in the middle. CPP row 926 error, initialization failure and other problems. Pay attention to the following points during deployment:

1. Make sure that the report template file *. rpt is in the correct path in the program you wrote, including deploying the running environment of the computer.

 

2. c:/program files/Microsoft sdks/Windows/v6.0a/bootstrapper/packages/crystalreports10_5 64-bit version and 32-bit version, I want to package and install a 32-bit system. The required files are crredist2008_x86.msi and crredist2008_x86_chs.msi.

 

3. it is important that many websites do not use this document, and some of them are also very vague. If you did not deploy it using the vs2008 deployment tool or your own installation package, there are three files: craxddrt. DLL, craxddrt_res_chs.dll, crviewer. DLL, which can be found in C:/program files/Business Objects/common/2.8/bin/. This is generated automatically after crredist2008_x86.msi is installed on the target machine, but is not registered, so you still need. DLL and crviewer. DLL.

 

Another important thing is that the versions of these files must be the same and comply with the environment you need. In my environment, the versions of the three files are 10.5.0.x, X may be different.

 

With the above operations, you can run an installation package that you write in a completely new environment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.