读出:
HRSRC hrSrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_EXE1), "EXE")
HGLOBAL hGlobal = LoadResource(AfxGetResourceHandle(), hrSrc)
LPVOID lpExe = LockResource(hGlobal)
//将数据保存在枝帆str
//char *lp=(char *)LockResource(hGlobal)
//CString str=lp
CFile file
if(file.Open("abc.exe"枝搭洞, CFile::modeCreate | CFile::modeWrite))
file.Write(lpExe, (UINT)SizeofResource(AfxGetResourceHandle(), hrSrc))
file.Close()
::UnlockResource(hGlobal)
::FreeResource(hGlobal)
#include <iostream.h>// using namespace std // MS VC++ comment out the line
#include "point.h"
#include "point.cpp"
void main(){
Point A(4,5)
cout<配或猜<"Point A,"<<A.getx()<<","<<A.gety()
A.getc()
Point B(A)
cout<<"Point B,"<<B.getx()<培型<","<<B.gety()
Point::getc()
}
--------------------------------------------
// point.cpp
int Point::count=0
Point::Point(Point &p){
X=p.XY=p.Ycount++}
----------------------------------
//团肢 point.h
class Point{
public:Point(int xx=0,int yy=0) {X=xxY=yycount++}
Point(Point &p)
~Point(){count--}
int getx(){return X}
int gety(){return Y}
static void getc(){cout<<"Object id="<<count<<endl}
private:int X,Y
static int count
}
---------------------------
MS VC++ 编译通过。
把下面的代码加入初始化函数InitInstance的顶部://或并腊调入资源DLL
m_hDemoDLL = AfxLoadLibrary(_T("Resource.dll"))
//告诉应用程序设置资源句柄蔽埋m_hDemoDLL;
AfxSetResourceHandle(m_hDemoDLL)
ExitInstance加入以下代码:
AfxFreeLibrary(m_hDemoDLL)//释放DLL资源;
在创建类型选择衫滑框New中选择MFC AppWizard(dll),创建一个新项目区,
在Step1中选择Regular DLL using MFC DLL,单击OK即可。
资源加入到DLL的rc文件中
使用DLL资源例:
CString strMessage//定义strMessage为Cstring字串类型
//从resource DLL中显示字串
strMessage.LoadString(IDS_DEMO)
pDC->TextOut(60,65,strMessage)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)