如何在VS VC 中DLL使用CString类
2013-12-31 10:08
274 查看
CString类用起来非常方便,可是如果不对默认的工程进行一些手术,就没法使用它
具体的修改方法如下,与大家分享一下。
在stdfax中加入下面的红色部分
// stdafx。h
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <afx.h> // 加在这里
// Windows Header Files:
#include <windows.h>
#ifdef _DEBUG
#pragma comment(lib, "libcmtd.lib")
#else
#pragma comment(lib, "libcmt.lib")
#endif
// Local Header Files
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
此时你的程序仍然不能使用Cstring,这是因为由于afx.h默认带了一个DllMain,致使要使用CString类需要几个步骤。
因此在你的dllMain之前加入下面的红色部分的代码即可。
#include "stdafx.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define new DEBUG_NEW
/////////////////////////////////////////////////////////////////////////////
// global data
// The following symbol used to force inclusion of this module for _USRDLL
#ifdef _X86_
extern "C" { int _afxForceUSRDLL; }
#else
extern "C" { int __afxForceUSRDLL; }
#endif
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
转载至 : /article/5484010.html
具体的修改方法如下,与大家分享一下。
在stdfax中加入下面的红色部分
// stdafx。h
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <afx.h> // 加在这里
// Windows Header Files:
#include <windows.h>
#ifdef _DEBUG
#pragma comment(lib, "libcmtd.lib")
#else
#pragma comment(lib, "libcmt.lib")
#endif
// Local Header Files
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
此时你的程序仍然不能使用Cstring,这是因为由于afx.h默认带了一个DllMain,致使要使用CString类需要几个步骤。
因此在你的dllMain之前加入下面的红色部分的代码即可。
#include "stdafx.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define new DEBUG_NEW
/////////////////////////////////////////////////////////////////////////////
// global data
// The following symbol used to force inclusion of this module for _USRDLL
#ifdef _X86_
extern "C" { int _afxForceUSRDLL; }
#else
extern "C" { int __afxForceUSRDLL; }
#endif
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
转载至 : /article/5484010.html
相关文章推荐
- 如何在VS VC 中DLL使用CString类
- (筆記) 如何使用Visual C++ 6.0開發Win32 DLL? (C/C++) (VC++)
- MinGW如何使用VC编译的DLL??
- 7.VC(custom)-解决DLL和主调程序的资源冲突及如何使用Dll的资源
- <转>VC在dll中使用CString类
- vc++ 2008 如何使用quartz.dll 获取影片的帧
- 如何在VC++中使用Windows Forms (VS2012-VS2015)
- VC2008如何生成及使用DLL(完整版)
- 在VC的控制台的程序中如何使用 cstring类
- VS 发布网站时如何产生固定命名的 Dll 文件 WebDeploymentSetup使用说明
- mingw如何使用VC编译的dll
- C#中如何使用VC++创建的dll动态链接库的返回参数
- 如何在VC.NET中制作并使用动态链接库DLL
- 使用VS调试时,被调试进程如何被断下来的。
- VC++ 6.0 中如何使用 CRT 调试功能来检测内存泄漏
- lib 和 dll 的区别与使用, 没有头文件改如何使用
- PowerShell 调用系统 DLL 中的函数,如何使用返回参数中的值
- 如何使用VS.NET调试数据库存储过程
- VS中如何使用NI控件画图
- 解析dll文件和 lib文件的区别(如何利用VC创建DLL文件)