我有一个DLL,导出了一个类:代码如下:
.h中:
#define DLL_INTERNAL __declspec( dllexport )class DLL_INTERNAL Cpp
{
public:
Cpp( const char *sSourceFileName );
void SS( const char *sTargetFileName );
protected:
virtual int HW( int inFile, int outFile ) = 0; char m_sSourceFileName[ MAX_PATH ];
};.cpp中:
Cpp::Cpp( const char *sUnzippedFileName )
{
strcpy( m_sSourceFileName, sUnzippedFileName );
}
void Cpp::SS( const char *sTargetFileName )
{ inFile = open( m_sSourceFileName, _O_BINARY | _O_RDONLY );
outFile = open( sTargetFileName, _O_BINARY | _O_RDWR | _O_CREAT | _O_EXCL , _S_IREAD | _S_IWRITE );
int ret = HW( inFile, outFile ); close( inFile );
close( outFile ); if (ret != 0)
{
/*
error process
*/
}
}
编译后将生成的lib和dll文件拷到系统目录下;OK! 现在我要新建一个工程调用这个类:
可不知该如何用,代码如下:
.h中:
#define DLL_INTERNAL __declspec( dllimport )
class DLL_INTERNAL Cpp
{
public:
Cpp( const char *sSourceFileName );
void SS( const char *sTargetFileName );
protected:
virtual int HW( int inFile, int outFile ) char m_sSourceFileName[ MAX_PATH ];
};.cpp中:
void main()
{
Cpp useCpp("e:\\temp\\dmm.dat");
useCpp.SS ("e:\\temp\\dmm");}
编译老通不过,我是个DLL初雪者,请各位大虾指点!!!!!!!!!!!!
.h中:
#define DLL_INTERNAL __declspec( dllexport )class DLL_INTERNAL Cpp
{
public:
Cpp( const char *sSourceFileName );
void SS( const char *sTargetFileName );
protected:
virtual int HW( int inFile, int outFile ) = 0; char m_sSourceFileName[ MAX_PATH ];
};.cpp中:
Cpp::Cpp( const char *sUnzippedFileName )
{
strcpy( m_sSourceFileName, sUnzippedFileName );
}
void Cpp::SS( const char *sTargetFileName )
{ inFile = open( m_sSourceFileName, _O_BINARY | _O_RDONLY );
outFile = open( sTargetFileName, _O_BINARY | _O_RDWR | _O_CREAT | _O_EXCL , _S_IREAD | _S_IWRITE );
int ret = HW( inFile, outFile ); close( inFile );
close( outFile ); if (ret != 0)
{
/*
error process
*/
}
}
编译后将生成的lib和dll文件拷到系统目录下;OK! 现在我要新建一个工程调用这个类:
可不知该如何用,代码如下:
.h中:
#define DLL_INTERNAL __declspec( dllimport )
class DLL_INTERNAL Cpp
{
public:
Cpp( const char *sSourceFileName );
void SS( const char *sTargetFileName );
protected:
virtual int HW( int inFile, int outFile ) char m_sSourceFileName[ MAX_PATH ];
};.cpp中:
void main()
{
Cpp useCpp("e:\\temp\\dmm.dat");
useCpp.SS ("e:\\temp\\dmm");}
编译老通不过,我是个DLL初雪者,请各位大虾指点!!!!!!!!!!!!
解决方案 »
- 做一个类似游戏登陆器的界面! 用什么技术 MFC 吗
- 看看我这么说对吗?
- 按一定时间间隔显示某一目录下的图片,是用SetTimer么
- OpenProcess 拒绝访问 怎么办??急求
- 送分题(100分):如何将一个CString转成CTime?
- 菜鸟提问:怎么样实现按照字母顺序进行排序?
- 现在做反病毒软件,一定用到VXD吗 ?
- 如何实现集合类?
- 如何在Visual C++上添加控件?
- VC应用程序ADO操作类直接返回结果集给前台,这样写好吗?
- InitializeCriticalSection(??)and CRITICAL_SECTION 的用法及作用
- 关于pascal?有题不会,先谢谢大家了
你干脆说神仙才能进吧
你应该这样:
#if defined _AFXDLL
#define DLL_INTERNAL __declspec( dllexport )
#else
#define DLL_INTERNAL __declspec( dllimport )
#endif
我先说我的做法把.不是很好.
就是作个基类,里面不做事情.写在dll里面的类从這兒繼承.然後把基类和.h編譯在project中
.dll中export一个特殊的函數返回类指針.project中就直接拿那个指針用.
cannot instantiate abstract class due to following members:
.h(17) : see declaration of 'Cpp'
这是个纯虚函数,所以你的类Cpp是不能有实例,找本c++的
书看下
你的这个函数是个纯虚函数,没有实现!你将这个函数的实现过程写出来,重新编译,然后在测试的CPP 编译后带上 生成的lib文件即可