【转】Using Visual C++ 2005 Express Edition with the Microsoft Platform SDK

from:
http://www.microsoft.com/express/2005/platformsdk/default.aspx


By Brian Johnson,
Microsoft Corporation

You can use Visual C++ Express to build powerful .NET Framework applications immediately after installation. In order to use Visual C++ Express to build Win32 applications, you'll need to take just a few more steps. I'll list the steps necessary for building Win32 applications using Visual C++ Express.
Step 1: Install Visual C++ Express.

If you haven't done so already, install Visual C++ Express.


Step 2: Install the Microsoft Platform SDK.

Install the Platform SDK over the Web from the Download Center. Follow the instructions and install the SDK for the x86 platform.


Step 3: Update the Visual C++ directories in the Projects and Solutions section in the Options dialog box.

Add the paths to the appropriate subsection:

    * Executable files: C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Bin
    * Include files: C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Include
    * Library files: C:/Program Files/Microsoft Platform SDK for Windows Server 2003 R2/Lib

Note: Alternatively, you can update the Visual C++ Directories by modifying the VCProjectEngine.dll.express.config file located in the /vc/vcpackages subdirectory of the Visual C++ Express install location. Please make sure that you also delete the file "vccomponents.dat" located in the "%USERPROFILE%/Local Settings/Application Data/Microsoft/VCExpress/8.0" if it exists before restarting Visual C++ Express Edition.


Step 4: Update the corewin_express.vsprops file.

One more step is needed to make the Win32 template work in Visual C++ Express. You need to edit the corewin_express.vsprops file (found in C:/Program Files/Microsoft Visual Studio 8/VC/VCProjectDefaults) and

Change the string that reads:

AdditionalDependencies="kernel32.lib"

to

AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"


Step 5: Generate and build a Win32 application to test your paths.

In Visual C++ Express, the Win32 Windows Application type is disabled in the Win32 Application Wizard. To enable that type, you need to edit the file AppSettings.htm file located in the folder %ProgramFiles%/Microsoft Visual Studio 8/VC/VCWizards/AppWiz/Generic/Application/html/1033/".

In a text editor comment out lines 441 - 444 by putting a // in front of them as shown here:

// WIN_APP.disabled = true;
// WIN_APP_LABEL.disabled = true;
// DLL_APP.disabled = true;
// DLL_APP_LABEL.disabled = true;

Save and close the file and open Visual C++ Express.

From the File menu, click New Project. In the New Project dialog box, expand the Visual C++ node in the Product Types tree and then click Win32. Click on the Win32 Console Application template and then give your project a name and click OK. In the Win32 Application Wizard dialog box, make sure that Windows application is selected as the Application type and the ATL is not selected. Click the Finish button to generate the project.

As a final step, test your project by clicking the Start button in the IDE or by pressing F5. Your Win32 application should build and run.

参考译文:

安装之后,您可以立即使用Visual C++ 2005速成版来生成功能强大的.NET Framework 应用程序。若要使用 Visual C++ 速成版生成Win32应用程序,只需采取几个步骤,下面对此进行了详细介绍。
  
1. 安装 Platform SDK 以便与 Visual C++ 速成版结合使用从 Platform SDK 更新站点 的 Platform SDK Update 站点通过 Web 安装 Microsoft Platform SDK。在该页上,单击“Download”(下载),然后确保从列表中依次选择“Windows SDK”和“Core SDK”。

2. 从 Visual Studio 中的“工具”菜单上,选择“选项”。出现“选项”对话框。
从“选项”对话框中,展开“项目和解决方案”节点并选择“VC++ 目录”。在该部分,将以下路径添加到相应的子节:
可执行文件:C:/Program Files/Microsoft SDK/Bin
包含文件:C:/Program Files/Microsoft SDK/include
库文件:C:/Program Files/Microsoft SDK/lib
    注意 在您的系统上,Platform SDK 的位置可能有所不同。

3. 更新 corewin_express.vsprops 文件
(位于C:/Program Files/Microsoft Visual Studio 8/VC/VCProjectDefaults 中)

并将以下字符串:

AdditionalDependencies="kernel32.lib"

更改为:

              AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"

注意 在您的系统上,Visual C++ 速成版 可能安装到了不同的位置。

4. 在Visual C++ 速成版,Win32应用程序向导上的Windows 应用程序选项是不可选的,要使用这个选项,你需要修改AppSettings.htm这个文件,它位于"%ProgramFiles%/ Microsoft Visual Studio 8/VC/VCWizards/AppWiz/Generic/Application/html/1033/".

在文本编辑器用"// "符号把文件里的441 - 444这几行注释掉,像下面这样:

// WIN_APP.disabled = true;

// WIN_APP_LABEL.disabled = true;

// DLL_APP.disabled = true;

// DLL_APP_LABEL.disabled = true;

保存和关闭文件,然后打开Visual C++ 速成版.

### 使用 Microsoft Visual C++ 2010 Express 实现数据库连接 #### 准备工作 为了成功地在 Microsoft Visual C++ 2010 Express 中实现与 SQL Server 数据库的连接,需先完成必要的准备工作。这包括安装合适的软件组件来确保开发环境具备访问数据库的能力。 - **安装Visual C++ 2010 Express**:此IDE不仅限于C/C++语言的支持,同时也为开发者提供了构建应用程序所需的工具集[^4]。 - **安装SQL Server**:可以选用随同Visual Studio系列一起提供的SQL Server Express版作为目标数据库服务器[^2]。 #### 配置ODBC数据源 建立到SQL Server的数据链接通常借助开放数据库连通性(ODBC),这是一种允许程序以统一方式存取不同类型的DBMS的标准接口。具体操作如下: - 打开控制面板找到“管理工具”,点击进入“ODBC Data Sources (32-bit)”设置向导; - 添加新的用户DSN或系统DSN,并按照提示选择对应的驱动程序(如`SQL Server Native Client 10.0`); - 输入有效的服务器名称、登录认证信息等参数完成配置; #### 编写代码实现连接逻辑 下面给出一段简单的C++代码片段用于展示如何利用ADO.NET技术栈,在Visual C++环境中执行基本的CRUD操作前首先要打开一个数据库会话: ```cpp #import "c:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "EndOfFile") using namespace std; using namespace ADODB; _ConnectionPtr pConnection(__uuidof(Connection)); _CommandPtr pCommand(__uuidof(Command)); try { // 设置连接字符串 _bstr_t strConn(L"Provider=SQLOLEDB;Data Source=localhost\\SQLEXPRESS;Initial Catalog=myDatabase;Integrated Security=SSPI;"); // 建立连接 pConnection->Open(strConn, "", "", adConnectUnspecified); cout << L"Connected to database successfully." << endl; } catch (_com_error &e) { cerr << e.Description() << endl; } finally{ if(pConnection!=NULL){ if(pConnection->State==adStateOpen) pConnection->Close(); } } // 清理COM对象 ::CoUninitialize(); ``` 这段代码展示了初始化 ADO 对象并尝试使用预定义好的 ODBC DSN 或者直接指定 Provider 和 DataSource 来获取远程/本地实例上的特定数据库连接的过程[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值