首先项目要加入SQL 支持
打开StkLib 中 StdAfx.h,加入
#ifndef _AFX_NO_STKLIBAFXADO_SUPPORT
#import “c:\program files\common files\system\ado\msado15.dll” \
no_namespace \
rename (“EOF”, “adoEOF”)
#define _AFX_NO_STKLIBAFXADO_SUPPORT
#endif
在项目StkLib中添加类 CStkLibWnd, 即添加了 StkLibWnd.h 与 StkLibWnd.cpp 两个文件
//////////////// StkLibWnd.h /////////////////
#if !defined(AFX_StkLibWnd_H____INCLUDED_)
#define AFX_StkLibWnd_H____INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif
#include “StdAfx.h”
class CStkLibWnd;
STKLIB_API CStkLibWnd& AfxGetCStkLibWnd(); //参考工程中其它项目的实例化,以后可以直接调用
struct COMM_PACKET;
class STKLIB_API CStkLibWnd //: public CWnd
{
public:
CStkLibWnd();
virtual ~CStkLibWnd(); //析构
bool test(); //用来测试
};
#endif
//////////////// StkLibWnd.cpp /////////////////
#include “StkLibWnd.h”
//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CStkLibWnd &AfxGetCStkLibWnd()
{
static CStkLibWnd g_stStkLibwnd;
return g_stStkLibwnd;
}
bool CStkLibWnd::test()
{
return true;
}
CStkLibWnd::CStkLibWnd()
{
}
CStkLibWnd::~CStkLibWnd()
{
}
//////
为了测试,修改Database.cpp文件,测试,能否正常运行
首先 SelfDB.h 加入相关头文件 #include “StkLibWnd.h”
修改 int CStDatabase::LoadCodetable( CStockContainer & container ) 函数
加入一行
bool bFlag = AfxGetCStkLibWnd().test();
如果编辑与运行正常通过,表示,编写方法正确,以后调整 读取文件的方法,只需要调用 AfxGetCStkLibWnd().同构函数,就可以了。
有人问为什么不直接改写其中一个钱龙的格式或FXJ的格式变成sql数据库,这里是个人经验,因为是派生类修改麻烦
class CSelfDB : public CQianlong = 》 class CQianlong : public IStStore
你要么就要改写全部,要么就编译不通过,当然,我也不是高手,如果有人有更方便的方法,请告诉我,QQ或者发邮件都可以, 不胜感激。