main
zgbjczw 1 year ago
parent 124eae5406
commit a2b7953084

@ -0,0 +1,454 @@
// BlackFinder.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <vector>
#include "BlackFinder.h"
#include "BlackList.h"
#include "global.h"
#include "WriteLog.h"
using namespace std;
static vector<CBlackList *> gBlackList;
HINSTANCE hDll = NULL;
FARPROC pFnOnDll = NULL;
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
hDll = ::LoadLibrary("kernel32.dll");
if(hDll)
{
pFnOnDll = ::GetProcAddress(hDll, "OpenThread");
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
if(hDll)
{
::FreeLibrary(hDll);
}
break;
}
return TRUE;
}
CBlackList* GetHashObj(HANDLE p, const bool bRemove)
{
for (vector<CBlackList *>::iterator it = gBlackList.begin(); it != gBlackList.end(); it++)
{
if (*it == (CBlackList *)p)
{
if (bRemove)
{
gBlackList.erase(it);
}
return (CBlackList *)p;
}
}
return NULL;
}
extern "C" BLACKFINDER_API HANDLE HASH_CreateList()
{
if (!pFnOnDll)
{
return NULL;
}
CBlackList *p = new CBlackList();
// WriteLog("HASH_CreateList p=%p", p);
if (p != NULL)
{
p->SetOpenThreadPtr((PFN_OpenThread)pFnOnDll);
gBlackList.push_back(p);
return (HANDLE)p;
}
return NULL;
}
extern "C" BLACKFINDER_API HRESULT HASH_DestroyList(HANDLE hHandle)
{
CBlackList *p = GetHashObj(hHandle, true);
if (p != NULL)
{
delete p;
return S_OK;
}
return ERR_INVALID_HANDLE;
}
extern "C" BLACKFINDER_API HRESULT HASH_LoadList(
HANDLE hHandle,char * pDBFFileName,char * pStrKeyFieldName)
{
int ilen;
WriteLog("HASH_LoadList para handle = %d,name = %s, key = %s",hHandle,pDBFFileName,pStrKeyFieldName);
if ((!hHandle) || (!pDBFFileName) || (!pStrKeyFieldName))
{
WriteLog("HASH_LoadList %d 参数错误",hHandle);
return ERR_LOAD_LIST_FAIL;
}
ilen =strlen(pDBFFileName);
if( (ilen <=0) || ( ilen >= 256) )
{
WriteLog("HASH_LoadList %d pDBFFileName 长度错误 %d",hHandle,ilen);
return ERR_LOAD_LIST_FAIL;
}
ilen =strlen(pStrKeyFieldName);
if( (ilen <=0) || ( ilen >= MAX_PRIKEYNAME_LEN) )
{
WriteLog("HASH_LoadList %d pStrKeyFieldName 长度错误 %d",hHandle,ilen);
return ERR_LOAD_LIST_FAIL;
}
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
if (pObj->Load(pDBFFileName, pStrKeyFieldName))
{
return S_OK;
}
else
{
// WriteLog("HASH_LoadList加载失败(%s)", pDBFFileName);
return ERR_LOAD_LIST_FAIL;
}
}
WriteLog("HASH_doLoadList:无效的句柄handle=%p", hHandle);
return ERR_INVALID_HANDLE;
}
extern "C" BLACKFINDER_API HRESULT HASH_LoadListBack(
HANDLE hHandle,HANDLE hMsgWnd,ULONG iMsgValue,ULONG iListId,
char * pMainDBFFileName,char * pSlaveDBFFileName,char * pStrKeyFieldName)
{
int ilen;
WriteLog("HASH_LoadListBack para handle = %d,msgwnd = %d ,iMsgValue = %d, ListId =%d,pMainDBFFileName = %s,pSlaveDBFFileName = %s, pStrKeyFieldName = %s",
hHandle,hMsgWnd,iMsgValue,iListId,pMainDBFFileName,pSlaveDBFFileName,pStrKeyFieldName);
if ((!hHandle) || (!hMsgWnd) || (!pMainDBFFileName)
|| (!pSlaveDBFFileName) || (!pStrKeyFieldName))
{
WriteLog("HASH_LoadListBack 参数错误");
return ERR_LOAD_LIST_BACK_FAIL;
}
ilen =strlen(pMainDBFFileName);
if( (ilen <=0) || ( ilen >= 256) )
{
WriteLog("HASH_LoadListBack %d pDBFFileName 长度错误 %d",hHandle,ilen);
return ERR_LOAD_LIST_BACK_FAIL;
}
ilen =strlen(pSlaveDBFFileName);
if( (ilen <=0) || ( ilen >= 256) )
{
WriteLog("HASH_LoadListBack %d pSlaveDBFFileName 长度错误 %d",hHandle,ilen);
return ERR_LOAD_LIST_BACK_FAIL;
}
ilen =strlen(pStrKeyFieldName);
if( (ilen <=0) || ( ilen >= MAX_PRIKEYNAME_LEN) )
{
WriteLog("HASH_LoadListBack %d pStrKeyFieldName 长度错误 %d",hHandle,ilen);
return ERR_LOAD_LIST_BACK_FAIL;
}
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
if(pObj->LoadListBack((HANDLE)hMsgWnd, iMsgValue, iListId, pMainDBFFileName, pSlaveDBFFileName, pStrKeyFieldName) == S_OK)
{
return S_OK;
}
else
{
WriteLog("HASH_LoadListBack加载失败(main %s)(slave %s)", pMainDBFFileName,pSlaveDBFFileName);
return ERR_LOAD_LIST_BACK_FAIL;
}
}
WriteLog("HASH_LoadListBack:无效的句柄handle=%p", hHandle);
return ERR_INVALID_HANDLE;
}
extern "C" BLACKFINDER_API HRESULT HASH_Find(
HANDLE hHandle,char * pStrKeyValue,char * pRetBuffer,int RetBufferLen)
{
int iRet;
string stemp;
string sname;
if ((!hHandle) || (!pStrKeyValue) || (!pRetBuffer) || (RetBufferLen <= 0))
{
WriteLog("HASH_Find %d 参数错误",hHandle);
return 0;
}
iRet =strlen(pStrKeyValue);
if(iRet <=0)
{
WriteLog("HASH_Find %d pStrKeyValue 为空",hHandle);
return 0;
}
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
bool bFound = false;
sname = pObj->GetDbfFileName();
stemp = pObj->GetPriKeyName();
// WriteLog("start find table %s prikey %s key %s",sname.c_str(),stemp.c_str(),pStrKeyValue);
string sInfo = pObj->Find(pStrKeyValue, bFound, false);
if (RetBufferLen > sInfo.length()) {
strcpy(pRetBuffer, sInfo.c_str());
}
else
{
WriteLog("HASH_Find:存储空间分配过小");
strcpy(pRetBuffer, "{\"RETCODE\":-1001,\"ERRORINFO\":\"存储空间分配过小\"}");
// return ERR_FIND_FAIL;
return 0;
}
if (bFound)
{
iRet = strlen(pRetBuffer);
stemp = pObj->GetPriKeyName();
// WriteLog("find key %s prikey is %s 返回 %s 长度 %d",pStrKeyValue,stemp.c_str(),pRetBuffer,iRet);
return iRet;
}
else
{
//return ERR_FIND_FAIL;
//iRet = strlen(pRetBuffer);
stemp = pObj->GetPriKeyName();
//WriteLog("find key %s prikey is %s 失败 返回 %s",pStrKeyValue,stemp.c_str(),sInfo.c_str());
// WriteLog("find key %s 失败",pStrKeyValue);
return 0;
}
}
strcpy(pRetBuffer, "{\"RETCODE\":-1000,\"ERRORINFO\":\"无效的句柄\"}");
WriteLog("HASH_Find:无效的句柄");
// return ERR_FIND_FAIL;
return 0;
}
extern "C" BLACKFINDER_API HRESULT HASH_Find2(
HANDLE hHandle,char * pStrKeyValue,char * pRetBuffer,int RetBufferLen)
{
int iRet;
string stemp;
string sname;
if ((!hHandle) || (!pStrKeyValue) || (!pRetBuffer) || (RetBufferLen <= 0))
{
WriteLog("HASH_Find2 参数错误");
return 0;
}
iRet =strlen(pStrKeyValue);
if(iRet <=0)
{
WriteLog("HASH_Find2 %d pStrKeyValue 为空",hHandle);
return 0;
}
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
sname = pObj->GetDbfFileName();
stemp = pObj->GetPriKeyName();
// WriteLog("start find table %s prikey %s key %s",sname.c_str(),stemp.c_str(),pStrKeyValue);
bool bFound = false;
string sInfo = pObj->Find(pStrKeyValue, bFound, true);
if (RetBufferLen > sInfo.length())
{
strcpy(pRetBuffer, sInfo.c_str());
}
else
{
WriteLog("HASH_Find2:存储空间分配过小");
strcpy(pRetBuffer, "{\"RETCODE\":-1001,\"ERRORINFO\":\"存储空间分配过小\"}");
return 0;
}
if (bFound)
{
iRet = strlen(pRetBuffer);
stemp = pObj->GetPriKeyName();
// WriteLog("find key %s table is %s prikey is %s 返回 %s 长度 %d",pStrKeyValue,sname.c_str(),stemp.c_str(),pRetBuffer,iRet);
return iRet;
}
else
{
stemp = pObj->GetPriKeyName();
// WriteLog("find key %s table is %s prikey is %s 失败,返回%s",pStrKeyValue,sname.c_str(),stemp.c_str(),sInfo.c_str());
// WriteLog("find key %s 失败",pStrKeyValue);
return 0;
}
}
strcpy(pRetBuffer, "{\"RETCODE\":-1000,\"ERRORINFO\":\"无效的句柄\"}");
WriteLog("HASH_Find2:无效的句柄");
return 0;
}
extern "C" BLACKFINDER_API HRESULT HASH_Find3(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pStrWhere,
/* [out] */char * pRetBuffer,
int RetBufferLen
)
{
int iRet;
string stemp;
string sname;
if ((!hHandle) || (!pStrWhere) || (!pRetBuffer) || (RetBufferLen <= 0))
{
WriteLog("HASH_Find3 参数错误");
return 0;
}
iRet =strlen(pStrWhere);
if(iRet <=0)
{
WriteLog("HASH_Find3 %d pStrWhere 为空",hHandle);
return 0;
}
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
sname = pObj->GetDbfFileName();
// stemp = pObj->GetPriKeyName();
// WriteLog("start find3 table %s where %s ",sname.c_str(),pStrWhere);
bool bFound = false;
string sInfo = pObj->FinDSqWhere(pStrWhere, bFound);
if (RetBufferLen > sInfo.length())
{
strcpy(pRetBuffer, sInfo.c_str());
}
else
{
WriteLog("HASH_Find3:存储空间分配过小");
strcpy(pRetBuffer, "{\"RETCODE\":-1001,\"ERRORINFO\":\"存储空间分配过小\"}");
return 0;
}
if (bFound)
{
iRet = strlen(pRetBuffer);
// WriteLog("find key %s table is %s prikey is %s 返回 %s 长度 %d",pStrKeyValue,sname.c_str(),stemp.c_str(),pRetBuffer,iRet);
return iRet;
}
else
{
//stemp = pObj->GetPriKeyName();
// WriteLog("find3 where %s table is %s 失败,返回%s",pStrWhere,sname.c_str(),sInfo.c_str());
// WriteLog("find key %s 失败",pStrKeyValue);
return 0;
}
}
strcpy(pRetBuffer, "{\"RETCODE\":-1000,\"ERRORINFO\":\"无效的句柄\"}");
WriteLog("HASH_Find2:无效的句柄");
return 0;
}
extern "C" BLACKFINDER_API HRESULT HASH_BackOnline(
HANDLE hHandle,char * pBlackFilePath,char * pBlackFileName)
{
int ilen;
WriteLog("HASH_BackOnline para handle = %d,pBlackFilePath = %s,pBlackFileName = %s",
hHandle,pBlackFilePath,pBlackFileName);
if ((!hHandle) || (!pBlackFilePath) || (!pBlackFileName))
{
WriteLog("HASH_BackOnline 参数错误");
return ERR_BACK_ON_LINE_FAIL;
}
ilen =strlen(pBlackFilePath);
if( (ilen <=0) || ( ilen >= 256) )
{
WriteLog("HASH_BackOnline %d pBlackFilePath 长度错误 %d",hHandle,ilen);
return ERR_BACK_ON_LINE_FAIL;
}
ilen =strlen(pBlackFileName);
if( (ilen <=0) || ( ilen >= 256) )
{
WriteLog("HASH_BackOnline %d pBlackFileName 长度错误 %d",hHandle,ilen);
return ERR_BACK_ON_LINE_FAIL;
}
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
if (pObj->BackOnline(pBlackFilePath, pBlackFileName) == S_OK)
{
return S_OK;
}
else {
WriteLog("HASH_BackOnline失败,HANDLE=%p, BlackFileName=%s", pObj, pBlackFileName);
return ERR_BACK_ON_LINE_FAIL;
}
}
WriteLog("HASH_BackOnline:无效的句柄handle=%p", hHandle);
return ERR_INVALID_HANDLE;
}
extern "C" BLACKFINDER_API HRESULT HASH_GetVerInfo(
HANDLE hHandle,char * pVerFieldName,char * pRetBuffer,int RetBufferLen)
{
if ((!hHandle) || (!pVerFieldName) || (!pRetBuffer) || (RetBufferLen <= 0))
{
WriteLog("HASH_GetVerInfo 参数错误");
return ERR_GET_VER_FAIL;
}
strcpy(pRetBuffer, "");
CBlackList *pObj = GetHashObj(hHandle, false);
if (pObj != NULL)
{
int RecordCount = 0;
string strVer = pObj->GetVerInfo(pVerFieldName, RecordCount);
if (strVer.length() < RetBufferLen)
{
strcpy(pRetBuffer, strVer.c_str());
}
return RecordCount;
}
WriteLog("HASH_GetVerInfo:无效的句柄:%s", pVerFieldName);
return ERR_INVALID_HANDLE;
}

@ -0,0 +1,172 @@
# Microsoft Developer Studio Project File - Name="BlackFinder" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=BlackFinder - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "BlackFinder.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "BlackFinder.mak" CFG="BlackFinder - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "BlackFinder - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "BlackFinder - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "BlackFinder - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BLACKFINDER_EXPORTS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BLACKFINDER_EXPORTS" /FR /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "NDEBUG"
# ADD RSC /l 0x804 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 sqlite3.lib WriteLogDLL.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"D:/test/BlackFinderTest/Debug/BlackFinder.dll"
!ELSEIF "$(CFG)" == "BlackFinder - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BLACKFINDER_EXPORTS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BLACKFINDER_EXPORTS" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "_DEBUG"
# ADD RSC /l 0x804 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 sqlite3.lib WriteLogDLL.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"D:/test/BlackFinderTest/Debug/BlackFinder.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "BlackFinder - Win32 Release"
# Name "BlackFinder - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BlackFinder.cpp
# End Source File
# Begin Source File
SOURCE=.\BlackList.cpp
# End Source File
# Begin Source File
SOURCE=.\CDBF.CPP
# End Source File
# Begin Source File
SOURCE=.\ModulePath.cpp
# End Source File
# Begin Source File
SOURCE=.\mySqlite.cpp
# End Source File
# Begin Source File
SOURCE=.\Script1.rc
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# Begin Source File
SOURCE=.\WriteLog.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\BlackFinder.h
# End Source File
# Begin Source File
SOURCE=.\BlackList.h
# End Source File
# Begin Source File
SOURCE=.\CDBF.H
# End Source File
# Begin Source File
SOURCE=.\global.h
# End Source File
# Begin Source File
SOURCE=.\ModulePath.h
# End Source File
# Begin Source File
SOURCE=.\mySqlite.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\WriteLog.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "BlackFinder"=.\BlackFinder.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

@ -0,0 +1,84 @@
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the BLACKFINDER_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// BLACKFINDER_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef BLACKFINDER_EXPORTS
#define BLACKFINDER_API __declspec(dllexport)
#else
#define BLACKFINDER_API __declspec(dllimport)
#endif
// This class is exported from the BlackFinder.dll
#define ERR_INVALID_HANDLE -1000
#define ERR_LOAD_LIST_FAIL -1001
#define ERR_LOAD_LIST_BACK_FAIL -1002
#define ERR_FIND_FAIL -1003
#define ERR_FIND2_FAIL -1004
#define ERR_BACK_ON_LINE_FAIL -1005
#define ERR_GET_VER_FAIL -1006
#define ERR_GET_BACK_LOAD_STATUS_FAIL -1007
#include "windows.h"
extern "C"
{
BLACKFINDER_API HANDLE HASH_CreateList();
BLACKFINDER_API HRESULT HASH_DestroyList(HANDLE hHandle);
BLACKFINDER_API HRESULT HASH_LoadList(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pDBFFileName,
/* [in] */ char * pStrKeyFieldName
);
BLACKFINDER_API HRESULT HASH_LoadListBack(
/* [in] */ HANDLE hHandle,
/* [in] */ HANDLE hMsgWnd,
/* [in] */ ULONG iMsgValue,
/* [in] */ ULONG iListId,
/* [in] */ char * pMainDBFFileName,
/* [in] */ char * pSlaveDBFFileName,
/* [in] */ char * pStrKeyFieldName
);
BLACKFINDER_API HRESULT HASH_Find(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pStrKeyValue,
/* [out] */ char * pRetBuffer,
int RetBufferLen
);
BLACKFINDER_API HRESULT HASH_Find2(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pStrKeyValue,
/* [out] */char * pRetBuffer,
int RetBufferLen
);
BLACKFINDER_API HRESULT HASH_Find3(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pStrWhere,
/* [out] */char * pRetBuffer,
int RetBufferLen
);
BLACKFINDER_API HRESULT HASH_BackOnline(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pBlackFilePath,
/* [in] */ char * pBlackFileName
);
BLACKFINDER_API HRESULT HASH_GetVerInfo(
/* [in] */ HANDLE hHandle,
/* [in] */ char * pVerFieldName,
/* [out] */ char * pRetBuffer,
/* [in] */ int RetBufferLen
);
};

@ -0,0 +1,64 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: BlackFinder - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating command line "rc.exe /l 0x804 /fo"Debug/Script1.res" /d "_DEBUG" "D:\test\BlackFinder\Script1.rc""
Creating temporary file "C:\Users\zgbjczw\AppData\Local\Temp\RSPE98F.tmp" with contents
[
/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BLACKFINDER_EXPORTS" /FR"Debug/" /Fp"Debug/BlackFinder.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"D:\test\BlackFinder\BlackFinder.cpp"
"D:\test\BlackFinder\BlackList.cpp"
"D:\test\BlackFinder\CDBF.CPP"
"D:\test\BlackFinder\ModulePath.cpp"
"D:\test\BlackFinder\mySqlite.cpp"
"D:\test\BlackFinder\WriteLog.cpp"
]
Creating command line "cl.exe @C:\Users\zgbjczw\AppData\Local\Temp\RSPE98F.tmp"
Creating temporary file "C:\Users\zgbjczw\AppData\Local\Temp\RSPE990.tmp" with contents
[
/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "BLACKFINDER_EXPORTS" /FR"Debug/" /Fp"Debug/BlackFinder.pch" /Yc"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"D:\test\BlackFinder\StdAfx.cpp"
]
Creating command line "cl.exe @C:\Users\zgbjczw\AppData\Local\Temp\RSPE990.tmp"
Creating temporary file "C:\Users\zgbjczw\AppData\Local\Temp\RSPE991.tmp" with contents
[
sqlite3.lib WriteLogDLL.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"Debug/BlackFinder.pdb" /debug /machine:I386 /out:"D:/test/BlackFinderTest/Debug/BlackFinder.dll" /implib:"Debug/BlackFinder.lib" /pdbtype:sept
.\Debug\BlackFinder.obj
.\Debug\BlackList.obj
.\Debug\CDBF.OBJ
.\Debug\ModulePath.obj
.\Debug\mySqlite.obj
.\Debug\StdAfx.obj
.\Debug\WriteLog.obj
.\Debug\Script1.res
]
Creating command line "link.exe @C:\Users\zgbjczw\AppData\Local\Temp\RSPE991.tmp"
<h3>Output Window</h3>
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
BlackFinder.cpp
BlackList.cpp
CDBF.CPP
ModulePath.cpp
mySqlite.cpp
WriteLog.cpp
Generating Code...
Linking...
Creating library Debug/BlackFinder.lib and object Debug/BlackFinder.exp
Creating command line "bscmake.exe /nologo /o"Debug/BlackFinder.bsc" .\Debug\StdAfx.sbr .\Debug\BlackFinder.sbr .\Debug\BlackList.sbr .\Debug\CDBF.SBR .\Debug\ModulePath.sbr .\Debug\mySqlite.sbr .\Debug\WriteLog.sbr"
Creating browse info file...
<h3>Output Window</h3>
<h3>Results</h3>
BlackFinder.dll - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

@ -0,0 +1,169 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<SccProjectName />
<SccLocalPath />
<ProjectGuid>{1F865B4F-7B6F-46F7-8827-A883CB48AB09}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\Debug\</OutDir>
<IntDir>.\Debug\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\Release\</OutDir>
<IntDir>.\Release\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<FunctionLevelLinking>false</FunctionLevelLinking>
<Optimization>Disabled</Optimization>
<SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel>
<MinimalRebuild>true</MinimalRebuild>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;BLACKFINDER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
<BrowseInformation>true</BrowseInformation>
<PrecompiledHeaderOutputFile>.\Debug\BlackFinder.pch</PrecompiledHeaderOutputFile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ObjectFileName>.\Debug\</ObjectFileName>
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
</ClCompile>
<Midl>
<SuppressStartupBanner>true</SuppressStartupBanner>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>.\Debug\BlackFinder.tlb</TypeLibraryName>
<MkTypLibCompatible>true</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Debug\BlackFinder.bsc</OutputFile>
</Bscmake>
<Link>
<SuppressStartupBanner>true</SuppressStartupBanner>
<LinkDLL>true</LinkDLL>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OutputFile>D:/test/BlackFinderTest/Debug/BlackFinder.dll</OutputFile>
<ImportLibrary>.\Debug\BlackFinder.lib</ImportLibrary>
<AdditionalDependencies>WriteLogDLL.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
<StringPooling>true</StringPooling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<Optimization>MaxSpeed</Optimization>
<SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;BLACKFINDER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
<PrecompiledHeaderOutputFile>.\Release\BlackFinder.pch</PrecompiledHeaderOutputFile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ObjectFileName>.\Release\</ObjectFileName>
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
</ClCompile>
<Midl>
<SuppressStartupBanner>true</SuppressStartupBanner>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>.\Release\BlackFinder.tlb</TypeLibraryName>
<MkTypLibCompatible>true</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
</Midl>
<ResourceCompile>
<Culture>0x0804</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release\BlackFinder.bsc</OutputFile>
</Bscmake>
<Link>
<SuppressStartupBanner>true</SuppressStartupBanner>
<LinkDLL>true</LinkDLL>
<SubSystem>Console</SubSystem>
<OutputFile>.\Release\BlackFinder.dll</OutputFile>
<ImportLibrary>.\Release\BlackFinder.lib</ImportLibrary>
<AdditionalDependencies>odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="BlackFinder.cpp" />
<ClCompile Include="BlackList.cpp" />
<ClCompile Include="CDBF.CPP" />
<ClCompile Include="ModulePath.cpp" />
<ClCompile Include="mySqlite.cpp" />
<ClCompile Include="StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdafx.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="WriteLog.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BlackFinder.h" />
<ClInclude Include="BlackList.h" />
<ClInclude Include="CDBF.H" />
<ClInclude Include="global.h" />
<ClInclude Include="ModulePath.h" />
<ClInclude Include="mySqlite.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="WriteLog.h" />
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{beffaae8-e005-401c-9a47-87ef150a3973}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{ddd836fe-7b9e-4e07-9258-e886c6690669}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{be0e585e-394a-4c30-91cb-688ff32c06d8}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="BlackFinder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BlackList.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="CDBF.CPP">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModulePath.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mySqlite.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StdAfx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WriteLog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BlackFinder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BlackList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="CDBF.H">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="global.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ModulePath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="mySqlite.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StdAfx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="WriteLog.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,134 @@
#pragma once
#include <string>
#include "CDBF.H"
#include "mySqlite.h"
#include "global.h"
using namespace std;
#define HASH_COUNT_MAX 50*1024 //
#define HASH_COUNT_PERCENT 100 //hash值比例
#define FILE_COPY_BUFFER_LEN (2*1024*1024)
#define HASH_BUFFER_RECCOUNT_PERBLOCK (128*1024) //一次分配256*1024*sizeof(HashNode)=2M
#define DB_TYPE_DBF 1
#define DB_TYPE_SQLITE 2
#pragma pack(push) //保存对齐状态
#pragma pack(1) // 1 bytes对齐
typedef struct tagHashNode {
unsigned short nHashValue;
//unsigned int nRecordNo;
tagHashNode *pNext;
}HashNode;
typedef struct {
unsigned short nNodeCount;
HashNode *pNode;
}HashHead;
#pragma pack(pop)
typedef struct {
HANDLE hMsgWnd;
unsigned int iMsgValue;
char MainDBFFileName[MAX_PATH + 1];
char SlaveDBFFileName[MAX_PATH + 1];
char strKeyFieldName[MAX_PATH + 1];
unsigned int iListId;
HANDLE hThread;
DWORD dwThreadId;
bool bThreadExit;
}THREADPARAMS;
typedef HashNode ** PNodeArray;
typedef struct {
CDBF *pDBF;
mySqlite * pSqlite;
// unsigned int type;
unsigned int nHeadBlockCount; //hash头数组分块数
unsigned int nHeadCount; //hash头数组元素总数
PNodeArray pHead; //邻接表 HashHead
unsigned int nNodeBlockCount; //节点内存分块数
unsigned int nNodeCount; //节点数,实际等于记录数
unsigned int nNodeUsed; //已使用节点
PNodeArray pNode; //二位节点指针数组 HashNode
}HASH_LIST;
typedef struct {
long nRecordNo[255];
}RECORDNO_ARRAY;
class CBlackList
{
private:
//char FileCopyBuffer[FILE_COPY_BUFFER_LEN];
CRITICAL_SECTION csFind;
CRITICAL_SECTION cs;
int iKeyFieldIndex;
HASH_LIST HashListMain;
HASH_LIST HashListSlave;
//czw 添加
PFN_OpenThread m_OpenThreadPtr;
int m_HashListType;
string m_PriKey;
string m_DbfName;
public:
THREADPARAMS threadParams;
private:
void FreeHashList(HASH_LIST &hashList);
int Open(HASH_LIST &hashList, const char *BlackFileName, const char *strKeyField);
unsigned int HashA(const char *lpszString, const int len);
unsigned int HashB(const char *lpszString, const int len);
unsigned int HashString(const char *lpszString, const int dwHashType);
bool MPQHashBuffAlloc(const int recordCount, HASH_LIST &hashList);
void MPQHashTableAdd(HASH_LIST &hashList, const char *lpszString,const unsigned int nRecordNo);
bool BuffAlloc(PNodeArray &pBlock, unsigned int &nAllocCount, const int nCount, const int iBlockCount,const int sizeBlock);
RECORDNO_ARRAY MPQHashTableIsExist(HASH_LIST &hashList, const char *lpszString, bool bFindAll);
bool BackThreadIsActive();
int GetRecordNo(HashNode *pNode);
//czw添加
int GetDbType(const char *BlackFileName);
bool OpenDbf(HASH_LIST &hashList, const char *BlackFileName, const char *strKeyField);
bool OpenSqlite(HASH_LIST &hashList, const char *BlackFileName, const char *strKeyField);
string FindDbf(const char *KeyValue, bool &bFound, const bool bFindAll);
string FindDSqlite(const char *KeyValue, bool &bFound, const bool bFindAll);
string GetVerInfoDbf(const char *VerFieldName, int &RecordCount);
string GetVerInfoSqlite(const char *VerFieldName, int &RecordCount);
public:
CBlackList();
~CBlackList();
bool Load(const char *BlackFileName, const char *strKeyField);
int LoadListBack(HANDLE hMsgWnd, unsigned int iMsgValue, unsigned int iListId,
char* MainDBFFileName, char *SlaveDBFFileName, char* strKeyFieldName);
bool doLoadListBack(const unsigned int iListID, const char *MainBlackFilePath, const char *BlackFileName, const char *strKeyField);
int BackOnline(const char *MainBlackFileName, const char *SlaveBlackFileName);
string Find(const char *KeyValue, bool &bFound, const bool bFindAll);
string FinDSqWhere(const char *pwhere, bool &bFound);
string GetVerInfo(const char *VerFieldName, int &RecordCount);
//czw 添加
void SetOpenThreadPtr(PFN_OpenThread ptr);
string GetPriKeyName();
string GetDbfFileName();
};

@ -0,0 +1,340 @@
#include "stdafx.h"
#include "CDBF.h"
#include <algorithm>
#include "WriteLog.h"
using namespace std;
CDBF::CDBF(){
FIsOpened = false;
ZeroMemory(&head, sizeof(Tdbf_head));
FFieldCount = 0;
FRecNo = 0;
FieldInfo = NULL;
FCurrentBuffer = NULL;
FBuffers = NULL;
FDBF = INVALID_HANDLE_VALUE;
}
CDBF::~CDBF(){
Close();
}
void CDBF::Close()
{
if(FDBF != INVALID_HANDLE_VALUE)
{
WriteLog("关闭DBF文件:%s", FDBFFileName.c_str());
FDBFFileName = "";
CloseHandle(FDBF);
FDBF = INVALID_HANDLE_VALUE;
};
FIsOpened = false;
FFieldCount = 0;
FRecNo = 0;
ZeroMemory(FRecNos, sizeof(FRecNos));
if(FCurrentBuffer != NULL){
free(FCurrentBuffer);
FCurrentBuffer = NULL;
}
if(FBuffers != NULL){
free(FBuffers);
FBuffers = NULL;
}
if(FieldInfo != NULL){
free(FieldInfo);
FieldInfo = NULL;
};
}
bool CDBF::GetFiledInfo(){
unsigned long fields_count, ReadCount;
int OffSet;
bool bGetFieldInfo = false;
FRecNo = 0;
OffSet = 0;
fields_count =(head.head_len-sizeof(Tdbf_head)-1) / sizeof(Tfield_element);
FFieldCount = fields_count;
bGetFieldInfo = true;
FieldInfo = (Tfield_element *)malloc(fields_count*sizeof(Tfield_element));
for (int i=0;i<fields_count;i++)
{
//BlockRead(FDBF, FieldInfo[i].field_name, sizeof(Tfield_element), ReadCount);
ReadFile(FDBF, &FieldInfo[i], sizeof(Tfield_element), &ReadCount, NULL);
FieldInfo[i].offset = OffSet;
OffSet += FieldInfo[i].field_length;
if (ReadCount != sizeof(Tfield_element)){
bGetFieldInfo = false;
break;
}
}
if (bGetFieldInfo == true) {
FCurrentBuffer = (char *)malloc(head.rec_len);
ZeroMemory(FCurrentBuffer, head.rec_len);
FBuffers = (char *)malloc(head.rec_len * PREREAD_RECORD_COUNT);
ZeroMemory(FBuffers, head.rec_len * PREREAD_RECORD_COUNT);
ZeroMemory(FRecNos, sizeof(FRecNos));
First();
}
return bGetFieldInfo;
};
bool CDBF::SetRecNo(const int nRecordNo){
unsigned long ReadCount;
int i;
if (nRecordNo == FRecNo){
return true;
}
if (nRecordNo > 0 && nRecordNo <= head.no_recs) {
for (i=0;i<PREREAD_RECORD_COUNT;i++)
if (nRecordNo == FRecNos[i]){
CopyMemory(FCurrentBuffer, &FBuffers[i*head.rec_len], head.rec_len);
FRecNo = nRecordNo;
return true;
}
}
//Seek(FDBF, head.head_len + (Value - 1) * head.rec_len + 1);
//BlockRead(FDBF, FBuffers[0], Head.rec_len * PREREAD_RECORD_COUNT, ReadCount);
LARGE_INTEGER li;
li.QuadPart = (__int64)head.head_len + (__int64)(nRecordNo - 1) * (__int64)head.rec_len + 1;
if(SetFilePointer(FDBF, li.LowPart, &li.HighPart, 0) != INVALID_SET_FILE_POINTER){
ReadFile(FDBF, FBuffers, head.rec_len * PREREAD_RECORD_COUNT, &ReadCount, NULL);
if (ReadCount >= head.rec_len){
CopyMemory(FCurrentBuffer, FBuffers, head.rec_len);
ZeroMemory(FRecNos, sizeof(FRecNos));
for(i=0;i<ReadCount / head.rec_len;i++) {
FRecNos[i] = nRecordNo + i;
};
FRecNo = nRecordNo;
return true;
}
}
return false;
}
void CDBF::First(){
SetRecNo(1);
}
void CDBF::Prior(){
SetRecNo(FRecNo - 1);
}
void CDBF::Next(){
SetRecNo(FRecNo + 1);
};
void CDBF::Last(){
SetRecNo(head.no_recs);
};
int CDBF::getFieldIndex(string FieldName){
for(int i=0; i<FFieldCount; i++){
string fa = FieldInfo[i].field_name;
fa.erase(0, fa.find_first_not_of(" "));
fa.erase(fa.find_last_not_of(" ") + 1);
transform(fa.begin(), fa.end(), fa.begin(), toupper);
string fb = FieldName;
fb.erase(0, fb.find_first_not_of(" "));
fb.erase(fb.find_last_not_of(" ") + 1);
transform(fb.begin(), fb.end(), fb.begin(), toupper);
if(fa.compare(fb) == 0)
return i;
}
return -1;
}
int CDBF::GetFieldCount(){
return FFieldCount;
};
int CDBF::GetFieldLength(int FieldNo){
int fieldLen = 0;
if (FieldNo < 1 || FieldNo > FFieldCount)
return fieldLen;
return FieldInfo[FieldNo - 1].field_length;
}
string CDBF::GetFieldName(int FieldNo){
if (FieldNo < 1 || FieldNo > FFieldCount)
return "";
return FieldInfo[FieldNo - 1].field_name;
}
string CDBF::GetFieldType(int FieldNo){
if (FieldNo < 1 || FieldNo > FFieldCount)
return "";
return &FieldInfo[FieldNo - 1].field_type;
}
string CDBF::GetFieldValue(int FieldNo){
if (FieldNo < 1 || FieldNo > FFieldCount)
return "";
size_t fieldLen = strlen(&FCurrentBuffer[FieldInfo[FieldNo - 1].offset]); ;
if(FieldInfo[FieldNo - 1].field_length < fieldLen)
{
fieldLen = FieldInfo[FieldNo - 1].field_length;
}
string Value(&FCurrentBuffer[FieldInfo[FieldNo - 1].offset], fieldLen);
Value.erase(0, Value.find_first_not_of(" "));
Value.erase(Value.find_last_not_of(" ") + 1);
transform(Value.begin(), Value.end(), Value.begin(), toupper);
return Value;
}
string CDBF::GetFieldValueByName(string FieldName){
int fieldIndex = getFieldIndex(FieldName);
return GetFieldValue(fieldIndex + 1);
}
int CDBF::GetRecordCount(){
if(FIsOpened)
return head.no_recs;
return 0;
};
string CDBF::GetFileDate()
{
if (FIsOpened)
{
FILETIME WriteTime;
if (GetFileTime(FDBF, NULL, NULL, &WriteTime))
{
FILETIME localTime;
if(FileTimeToLocalFileTime(&WriteTime, &localTime))
{
SYSTEMTIME sysTime;
if (FileTimeToSystemTime(&localTime, &sysTime))
{
char strTime[50] = {0};
sprintf(strTime, "%04d-%02d-%02dT%02d:%02d:%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
return strTime;
}
}
}
}
return "2000-01-01T00:00:00";
}
bool CDBF::Open(string FileName){
unsigned long ReadCount;
unsigned long LFileCount;
unsigned long HFileCount;
__int64 iFileSize;
__int64 iFileSize2;
bool bGetFieldInfo = false;
if (FIsOpened){
WriteLog("文件已经打开:%s", FileName.c_str());
return true;
}
//WriteLog("关闭文件开始:%s", FileName.c_str());
Close();
//WriteLog("关闭文件完成:%s", FileName.c_str());
//AssignFile(FDBF, FileName);
FDBF = CreateFile(FileName.c_str(), GENERIC_READ , FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0);
if (FDBF != INVALID_HANDLE_VALUE){
FRecNo = 0;
//Reset(FDBF, 1);
//BlockRead(FDBF, head, sizeof(Tdbf_head), ReadCount);
ReadFile(FDBF, &head, sizeof(Tdbf_head), &ReadCount, NULL);
if (ReadCount == sizeof(Tdbf_head)) {
if (head.vers==0x02 || head.vers==0x03 || head.vers==0x30 ||
head.vers==0x43 || head.vers==0x63 || head.vers==0x83 ||
head.vers==0x8B || head.vers==0xCB || head.vers==0xF5 || head.vers==0xFB){
//iFileSize := FileSize(FDBF);
FDBFFileName = FileName;
LFileCount = GetFileSize(FDBF, &HFileCount);
iFileSize = HFileCount;
iFileSize = (iFileSize << 32) | LFileCount;
iFileSize2 = head.rec_len;
iFileSize2 *= head.no_recs;
iFileSize2 += head.head_len + 1;
if (iFileSize <= iFileSize2 + 1 && iFileSize >= iFileSize2 - 1){
bGetFieldInfo = GetFiledInfo();
if(bGetFieldInfo == false){
WriteLog("获取字段信息失败(%s)");
}
}else{
WriteLog("文件大小校验失败(%s)", FileName.c_str());
}
}else{
WriteLog("文件头信息校验失败(%s)", FileName.c_str());
}
}else{
WriteLog("读取文件头信息失败(%s)", FileName.c_str());
}
} else {
WriteLog("打开文件失败(%s), error=%d", FileName.c_str(), GetLastError());
}
FIsOpened = bGetFieldInfo;
if (bGetFieldInfo == false)
{
Close();
};
return FIsOpened;
};
int CDBF::GetRecordSize(){
return head.rec_len;
}
void *CDBF::GetActiveBuffer(){
return FCurrentBuffer;
}
bool CDBF::IsOpened()
{
return FIsOpened;
}
int CDBF::GetRecNo()
{
return FRecNo;
}
string CDBF::GetDBFFileName()
{
return FDBFFileName;
}

@ -0,0 +1,86 @@
#ifndef _CDBF_H_
#define _CDBF_H_
//#include "stdafx.h"
#include <windows.h>
#include <string>
using namespace std;
#define PREREAD_RECORD_COUNT 100
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
#pragma pack(push)
#pragma pack(1)
typedef struct {
unsigned char vers;
unsigned char yy,mm,dd;
unsigned int no_recs;
unsigned short head_len;
unsigned short rec_len;
char reserved[20];
} Tdbf_head;
typedef struct {
char field_name[11];
char field_type;
unsigned int offset;
unsigned char field_length;
unsigned char field_decimal;
char reserved1[2];
unsigned char dbaseiv_id;
char reserved2[11];
} Tfield_element;
#pragma pack(pop)
class CDBF{
private:
HANDLE FDBF;
bool FIsOpened;
int FRecNo;
string FDBFFileName;
Tdbf_head head;
int FFieldCount;
Tfield_element *FieldInfo;
char *FCurrentBuffer;
char *FBuffers;
int FRecNos[PREREAD_RECORD_COUNT];
bool GetFiledInfo();
int GetRecordSize();
void *GetActiveBuffer();
int GetFieldLength(int FieldNo);
public:
CDBF();
~CDBF();
bool Open(string FileName);
void Close();
void First();
void Next();
void Last();
void Prior();
bool SetRecNo(const int nRecordNo);
bool IsOpened();
int getFieldIndex(string FieldName);
string GetFieldValue(int FieldNo);
string GetFieldValueByName(string FieldName);
string GetFieldName(int FieldNo);
string GetFieldType(int FieldNo);
int GetFieldCount();
int GetRecordCount();
int GetRecNo();
string GetDBFFileName();
string GetFileDate();
};
#endif

@ -0,0 +1,108 @@
#include "stdafx.h"
#include "ModulePath.h"
const char kEndChar = '\0';
const char kFilePathSeparators[] = "\\/";
HMODULE CModulePath::GetModuleHandleFromAddress(void *address)
{
MEMORY_BASIC_INFORMATION mbi;
DWORD result = ::VirtualQuery(address, &mbi, sizeof(mbi));
if (result != sizeof(mbi))
{
return static_cast<HMODULE>(0);
}
return static_cast<HMODULE>(mbi.AllocationBase);
}
bool CModulePath::IsModuleHandleValid(HMODULE module_handle)
{
if (!module_handle)
{
return false;
}
return module_handle == GetModuleHandleFromAddress(module_handle);
}
HMODULE CModulePath::GetCurrentModuleHandle()
{
return GetModuleHandleFromAddress((void*)GetCurrentModuleHandle);
}
string CModulePath::GetModulePathName(HMODULE module_handle)
{
string mod_path;
if (IsModuleHandleValid(module_handle))
{
mod_path.resize(MAX_PATH);
mod_path.resize(::GetModuleFileName(module_handle, &mod_path[0], mod_path.size()));
}
return mod_path;
}
bool CModulePath::IsFilePathSeparator(const char separator)
{
if (separator == kEndChar)
{
return false;
}
size_t len = sizeof(kFilePathSeparators) / sizeof(wchar_t);
for (size_t i = 0; i < len; i++)
{
if (separator == kFilePathSeparators[i])
{
return true;
}
}
return false;
}
bool CModulePath::FilePathApartDirectory(const string &filepath_in, string &directory_out)
{
size_t index = filepath_in.size() - 1;
if (index <= 0 || filepath_in.size() == 0)
{
return false;
}
for (; index != 0; index--)
{
if (IsFilePathSeparator(filepath_in[index]))
{
if (index == filepath_in.size() - 1)
{
directory_out = filepath_in;
}
else
{
directory_out = filepath_in.substr(0, index + 1);
}
return true;
}
}
return false;
}
string CModulePath::GetModuleDirectory(HMODULE module_handle)
{
string module_directory;
if (IsModuleHandleValid(module_handle))
{
if (FilePathApartDirectory(GetModulePathName(module_handle), module_directory))
{
return module_directory;
}
}
return "";
}
string CModulePath::GetCurrentModuleDirectory()
{
return GetModuleDirectory(GetCurrentModuleHandle());
}

@ -0,0 +1,24 @@
#ifndef GETMODULEPATH
#define GETMODULEPATH
#include <string>
#include "windows.h"
using namespace std;
/**
* @class getmodulepath
* @brief
*/
class CModulePath
{
public:
static HMODULE GetModuleHandleFromAddress(void* address);
static bool IsModuleHandleValid(HMODULE module_handle);
static HMODULE GetCurrentModuleHandle();
static string GetModulePathName(HMODULE module_handle);
static bool IsFilePathSeparator(const char separator);
static bool FilePathApartDirectory(const string &filepath_in, string &directory_out);
static string GetModuleDirectory(HMODULE module_handle);
static string GetCurrentModuleDirectory();
};
#endif // GETMODULEPATH

@ -0,0 +1,37 @@
========================================================================
DYNAMIC LINK LIBRARY : BlackFinder
========================================================================
AppWizard has created this BlackFinder DLL for you.
This file contains a summary of what you will find in each of the files that
make up your BlackFinder application.
BlackFinder.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
BlackFinder.cpp
This is the main DLL source file.
BlackFinder.h
This file contains your DLL exports.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named BlackFinder.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

@ -0,0 +1,124 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Chinese (P.R.C.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,4
PRODUCTVERSION 1,0,0,4
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", " \0"
VALUE "FileDescription", "BlackFinder\0"
VALUE "FileVersion", "1, 0, 0, 4\0"
VALUE "InternalName", "BlackFinder\0"
VALUE "LegalCopyright", "Copyright ? 2023\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "BlackFinder.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", " BlackFinder\0"
VALUE "ProductVersion", "1, 0, 0, 4\0"
VALUE "SpecialBuild", "\0"
END
BLOCK "080404b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "北京天润科丰科技有限公司\0"
VALUE "FileDescription", "BlackFinder\0"
VALUE "FileVersion", "1, 0, 0, 4\0"
VALUE "InternalName", "BlackFinder\0"
VALUE "LegalCopyright", "Copyright ? 2023\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "BlackFinder.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", " BlackFinder\0"
VALUE "ProductVersion", "1, 0, 0, 4\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200, 0x804, 1200
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Chinese (P.R.C.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// BlackFinder.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

@ -0,0 +1,24 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__45106C46_A79F_4B4E_8417_0136F562A109__INCLUDED_)
#define AFX_STDAFX_H__45106C46_A79F_4B4E_8417_0136F562A109__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__45106C46_A79F_4B4E_8417_0136F562A109__INCLUDED_)

@ -0,0 +1,45 @@
#include "stdafx.h"
#include "WriteLog.h"
#include "ModulePath.h"
#include <stdarg.h>
static string logFileName;
void WriteLog(char *format, ...)
{
/* 初始时假设我们只需要不超过100字节大小的空间 */
int n, size = 1024;
char *p;
va_list ap;
if ( (p = (char *) malloc(size*sizeof(char))) == NULL)
{
return;
}
while (1)
{
/* 尝试在申请的空间中进行打印操作 */
va_start(ap, format);
n = _vsnprintf (p, size, format, ap);
va_end(ap);
/* 如果vsnprintf调用成功返回该字符串 */
if (n > -1 && n < size)
{
if(logFileName.empty())
{
logFileName = CModulePath::GetCurrentModuleDirectory();
logFileName += "log/BlackFinder.log";
}
WriteLog2(logFileName.c_str(), p, 10, 10*1024*1024);
free(p);
return;
}
/* vsnprintf调用失败(n<0)或者p的空间不足够容纳size大小的字符串(n>=size),尝试申请更大的空间*/
size += 1024; /* 两倍原来大小的空间 */
if ((p = (char *)realloc(p, size*sizeof(char))) == NULL)
{
return;
}
}
}

@ -0,0 +1,9 @@
#ifndef _WRITE_LOG_DLL_H
#define _WRITE_LOG_DLL_H
void __stdcall WriteLog2(const char *pFileName,const char *pStrCon, int FileCount, int logFileSize);
void WriteLog(char *format, ...);
#endif

@ -0,0 +1,63 @@
#ifndef _GLOBAL_H_
#define _GLOBAL_H_
typedef HANDLE (WINAPI* PFN_OpenThread)(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwThreadId);
#endif

@ -0,0 +1,970 @@
// mySqlite.cpp: implementation of the mySqlite class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mySqlite.h"
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "WriteLog.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
mySqlite::mySqlite()
{
m_dbptr = NULL;
m_RecordCount = 0;
m_SqliteFileName = "";
m_SqlVersion = "";
m_IdxFlag =0;
memset(m_PriKey, 0, sizeof(m_PriKey));
}
mySqlite::~mySqlite()
{
}
int mySqlite::toWString(wstring &deststr,const string& sourcestr, unsigned int code)
{
std::wstring wstr;
int len;
int iret;
len = MultiByteToWideChar(code, 0, sourcestr.c_str(), -1, NULL, 0);
if (0 == len)
{
return -1;
}
wstr.resize(static_cast<size_t>(len + 1));
iret = MultiByteToWideChar(code, 0, sourcestr.c_str(), -1, const_cast<wchar_t*>(wstr.c_str()), len);
if (0 == len)
{
return -2;
}
deststr = wstr;
return 0;
}
int mySqlite::toYString(string& deststr,const std::wstring& sourcestr, unsigned int code )
{
string ystr;
int len;
// int iret;
len = WideCharToMultiByte(code, 0, sourcestr.c_str(), -1, NULL, 0, NULL, NULL);
if (0 == len)
{
return -1;
}
ystr.resize(static_cast<size_t>(len - 1));
len = WideCharToMultiByte(code, 0, sourcestr.c_str(), -1, const_cast<char*>(ystr.c_str()), len, NULL, NULL);
if (0 == len)
{
return -2;
}
deststr = ystr;
return 0;
}
int mySqlite::GbkToUtf8(string & utf8str, const string& gbkstr)
{
int iret;
wstring wstr;
string ystr;
iret = gbkstr.length();
if(iret <= 0)
{
return 0;
}
iret = toWString(wstr, gbkstr, CP_ACP);
if (iret < 0)
{
return -1;
}
iret = toYString(ystr, wstr);
if (iret < 0)
{
return -2;
}
utf8str = ystr;
return 0;
}
int mySqlite::Utf8ToGbk(string & gbkstr, const string& utf8str)
{
int iret;
wstring wstr;
string ystr;
iret = utf8str.length();
if (iret <= 0)
{
return 0;
}
iret = toWString(wstr, utf8str);
if (iret < 0)
{
return -1;
}
iret = toYString(ystr, wstr, CP_ACP);
if (iret < 0)
{
return -2;
}
gbkstr = ystr;
return 0;
}
bool mySqlite::Open(const char * pName, const char * pKey)
{
int iRet;
iRet = GetSqlTmpName(pName);
if (iRet < 0)
{
WriteLog("GetSqlTmpName 失败, 返回值 %d",pName, iRet);
return false;
}
iRet = SetPriKey(pKey);
if (iRet < 0)
{
WriteLog("SetPriKey 失败,key %s 返回值 %d",pKey, iRet);
return false;
}
Close();
iRet = GetWriteTime(pName);
if (iRet < 0)
{
WriteLog("文件 %s 获取时间失败, 返回值 %d",pName, iRet);
return false;
}
iRet = sqlite3_open(pName, &m_dbptr);
if (iRet != SQLITE_OK)
{
sqlite3_close(m_dbptr);
m_dbptr = NULL;
WriteLog("文件 %s sqlite3_open失败",pName);
return false;
}
WriteLog("文件 %s 打开成功",pName);
m_SqliteFileName = pName;
iRet = GetTableName();
if(iRet < 0)
{
Close();
WriteLog("文件 %s 获取表名失败,返回值 %d",pName,iRet);
return false;
}
iRet = GetCountAndVerSion();
if(iRet < 0)
{
Close();
WriteLog("文件 %s 获取记录和版本失败,返回值 %d",pName,iRet);
return false;
}
return true;
}
void mySqlite::Close()
{
if (m_dbptr)
{
sqlite3_close(m_dbptr);
m_dbptr = NULL;
}
}
int mySqlite::SetPriKey(const char * pKey)
{
int iRet;
iRet = strlen(pKey);
if (iRet >= MAX_PRIKEYNAME_LEN)
{
// WriteLog("key %s 长度太长",pKey);
return -1;
}
strcpy(m_PriKey, pKey);
return 0;
}
bool mySqlite::IsOpened()
{
if (m_dbptr)
{
return true;
}
return false;
}
string mySqlite::GetDBFFileName()
{
return m_SqliteFileName;
}
int mySqlite::GetSqlTmpName(const char * pName)
{
char buf[320];
// int iret;
int i;
int ilen;
char * ptr;
ilen = strlen(pName);
if(ilen >256)
{
// WriteLog("文件名 %s 超过规定长度",pName);
return -1;
}
memset(buf,0,sizeof(buf));
strcpy(buf,pName);
for(i =ilen -1; i>=0; i--)
{
if(('\\' == buf[i]) || ('/' == buf[i]))
{
ptr = buf+i+1;
break;
}
}
ilen = strlen(ptr);
for(i =ilen -1; i>0; i--)
{
if('.' == ptr[i])
{
ptr[i] ='\0';
break;
}
}
ilen = strlen(ptr);
for(i =ilen -1; i>0; i--)
{
if('_' == ptr[i])
{
ptr[i] ='\0';
break;
}
}
m_SqliteTmpName = ptr;
return 0;
}
int mySqlite::GetTableName()
{
if (!m_dbptr)
{
return -1;
}
int iRet;
int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
char * ptr;
int iFlag;
iFlag = 0;
try
{
iRet = sqlite3_get_table(m_dbptr, SQL_GETTABLENAME_STR, &dbResult, &nRow, &nColumn, &errmsg);
if(SQLITE_OK != iRet)
{
WriteLog("数据库 %s sql 语句 %s 执行错误",m_SqliteFileName.c_str(),SQL_GETTABLENAME_STR);
iFlag =1;
sqlite3_free_table(dbResult);
return -101;
}
//查询成功
if(0 == nRow)
{
// WriteLog("数据库 %s sql 语句 %s 查询结果记录为0",m_SqliteFileName,SQL_GETTABLENAME_STR);
sqlite3_free_table(dbResult);
return -2;
}
if(nColumn != 1)
{
// WriteLog("数据库 %s sql 语句 %s 查询返回字段数不是1",m_SqliteFileName,SQL_GETTABLENAME_STR);
sqlite3_free_table(dbResult);
return -3;
}
int i;
for(i=0; i<nRow; i++)
{
ptr = dbResult[nColumn * (i + 1)];
if(0 == (strcmp(ptr,SQL_IDXTAB_STR)))
{
m_IdxFlag =1;
break;
}
}
if(0 == m_IdxFlag)
{
WriteLog("数据库 %s 没有表",SQL_IDXTAB_STR);
sqlite3_free_table(dbResult);
return -4;
}
for(i=0; i<nRow; i++)
{
ptr = dbResult[nColumn * (i + 1)];
if(0 == (strcmp(ptr,SQL_BLACKTAB_STR)))
{
m_TableName = SQL_BLACKTAB_STR;
sqlite3_free_table(dbResult);
return 0;
break;
}
}
for(i=0; i<nRow; i++)
{
ptr = dbResult[nColumn * (i + 1)];
iLen = strlen(ptr);
if(m_SqliteTmpName.length() == iLen)
{
if(0 == (strnicmp(ptr,m_SqliteTmpName.c_str(), iLen)))
{
m_TableName = ptr;
sqlite3_free_table(dbResult);
return 0;
break;
}
}
}
// WriteLog("数据库 %s 未找到符合条件的表",m_SqliteFileName);
sqlite3_free_table(dbResult);
return -5;
}
catch (...)
{
if (0 == iFlag)
{
sqlite3_free_table(dbResult);
}
WriteLog("数据库 %s sql 语句 %s 异常",m_SqliteFileName.c_str(),SQL_GETTABLENAME_STR);
//sRecord = "{\"RETCODE\":-100,\"ERRORINFO\":\"异常跳出\"}";
return -100;
}
return 0;
}
int mySqlite::GetCountAndVerSion()
{
if (!m_dbptr)
{
return -1;
}
if( m_IdxFlag !=1)
{
return -2;
}
int iRet;
int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
//char buf[16];s'q
int iFlag;
iFlag =0;
try
{
iRet = sqlite3_get_table(m_dbptr, SQL_GETCOUNTANDVER_STR, &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
WriteLog("数据库 %s sql 语句 %s 查询失败",m_SqliteFileName.c_str(),SQL_GETCOUNTANDVER_STR);
iFlag =1;
sqlite3_free_table(dbResult);
return -101;
}
if(0 == nRow)
{
// WriteLog("数据库 %s sql 语句 %s 查询结果记录为0",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -3;
}
if(nColumn != 2)
{
// WriteLog("数据库 %s sql 语句 %s 查询返回字段数不是2",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -4;
}
iLen = strlen(dbResult[0]);
if(iLen >128)
{
// WriteLog("数据库 %s sql 语句 %s 查询 版本太长",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -5;
}
m_SqlVersion = dbResult[2];
iLen = strlen(dbResult[3]);
if (iLen > 10)
{
//Close();
//WriteLog("数据库 %s sql 语句 %s 查询记录数 太长",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -6;
}
iRet = isnumer(dbResult[3]);
if(iRet <0)
{
//WriteLog("数据库 %s sql 语句 %s 查询记录数 不是数字",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -7;
}
m_RecordCount = atoi(dbResult[3]);
sqlite3_free_table(dbResult);
}
catch (...)
{
if (0 == iFlag)
{
sqlite3_free_table(dbResult);
}
WriteLog("数据库 %s sql 语句 %s 异常",m_SqliteFileName.c_str(),SQL_GETCOUNTANDVER_STR);
//sRecord = "{\"RETCODE\":-100,\"ERRORINFO\":\"异常跳出\"}";
return -100;
}
return 0;
}
int mySqlite::GetRecordCount()
{
return m_RecordCount;
}
string mySqlite::GetSqlVersion()
{
return m_SqlVersion;
}
string mySqlite::SqlFind(const char *KeyValue, bool &bFound, const bool bFindAll)
{
if (!m_dbptr)
{
bFound = false;
return "{\"RETCODE\":-5,\"ERRORINFO\":\"SQL文件未打开\"}";
}
int iRet;
// int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
string stemp,sRecord,skey;
int iFlag = 0;
//char buf[16];
bFound = false;
iRet = strlen(KeyValue);
if (iRet > MAX_PRIKEYVALUE_LEN)
{
return "{\"RETCODE\":-6,\"ERRORINFO\":\"主键字符串太长\"}";
}
iRet = GbkToUtf8(skey,KeyValue);
if(iRet <0)
{
WriteLog("sqlfind %s 转换 utf8 失败",KeyValue);
return "{\"RETCODE\":-104,\"ERRORINFO\":\"字符串转utf8 失败\"}";
}
stemp = "SELECT * FROM ";
stemp.append(m_TableName);
stemp.append(" WHERE ");
stemp.append(m_PriKey);
stemp.append("='");
stemp.append(skey);
stemp.append("'");
try
{
iRet = sqlite3_get_table(m_dbptr, stemp.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
sqlite3_free_table(dbResult);
iFlag = 1;
WriteLog("数据库 %s sql 语句 %s 执行失败",m_SqliteFileName.c_str(),stemp.c_str());
return "{\"RETCODE\":-7,\"ERRORINFO\":\"SQL 执行错误\"}";
}
if(0 == nRow)
{
sqlite3_free_table(dbResult);
// WriteLog("数据库 %s sql 语句 %s 查询 未找到",m_SqliteFileName,stemp.c_str());
iFlag = 1;
return "{\"RETCODE\":-8,\"ERRORINFO\":\"SQL 未找到记录\"}";
}
bFound = true;
if (!bFindAll)
{
sRecord = "{\"RETCODE\":1";
iRet = nColumn ;
for (int j = 0; j < nColumn; j++)
{
sRecord.append(",\"");
sRecord.append(dbResult[j]);
sRecord.append("\":\"");
if(dbResult[iRet])
{
sRecord.append(dbResult[iRet]);
}
sRecord.append("\"");
iRet++;
}
sRecord.append(",\"backup2\":\"");
sRecord.append(m_SqlVersion);
sRecord += "\"}";
sqlite3_free_table(dbResult);
iFlag = 1;
stemp ="";
iRet = Utf8ToGbk(stemp,sRecord);
if(iRet <0)
{
bFound = false;
stemp = "{\"RETCODE\":-101,\"ERRORINFO\":\"字符串转换失败\"}";
}
return stemp;
}
stemp = "";
sRecord = "{\"RETCODE\":1,\"DATA\":[";
for (int i = 0; i < nRow; i++)
{
if (0 == i)
{
stemp.append("{");
}
else
{
stemp.append(",{");
}
iRet = nColumn * (i + 1);
for (int j = 0; j < nColumn; j++)
{
if (j > 0)
{
stemp.append(",");
}
stemp.append("\"");
stemp.append(dbResult[j]);
stemp.append("\":\"");
if(dbResult[iRet])
{
stemp.append(dbResult[iRet]);
}
stemp.append("\"");
iRet++;
}
stemp.append(",\"backup2\":\"");
stemp.append(m_SqlVersion);
stemp.append("\"}");
}
sRecord.append(stemp);
sRecord.append("]}");
}
catch (...)
{
if (0 == iFlag)
{
sqlite3_free_table(dbResult);
}
WriteLog("数据库 %s sql 语句 %s 执行异常",m_SqliteFileName.c_str(),stemp.c_str());
sRecord = "{\"RETCODE\":-100,\"ERRORINFO\":\"异常跳出\"}";
return sRecord;
}
sqlite3_free_table(dbResult);
stemp ="";
iRet = Utf8ToGbk(stemp,sRecord);
if(iRet <0)
{
bFound = false;
WriteLog("sqlfind %s 转换 gbk 失败",sRecord.c_str());
stemp = "{\"RETCODE\":-101,\"ERRORINFO\":\"字符串转换失败\"}";
}
return stemp;
}
string mySqlite::FindWhere(const char *pWhere, bool &bFound)
{
if (!m_dbptr)
{
bFound = false;
return "{\"RETCODE\":-5,\"ERRORINFO\":\"SQL文件未打开\"}";
}
int iRet;
// int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
//sqlite3_stmt *stmt;
int nRow, nColumn;
string stemp,sRecord,skey;
int iFlag = 0;
//char buf[16];
bFound = false;
iRet = GbkToUtf8(skey,pWhere);
if(iRet <0)
{
WriteLog("FindWhere %s 转换 utf8 失败",pWhere);
return "{\"RETCODE\":-104,\"ERRORINFO\":\"字符串转utf8 失败\"}";
}
stemp = "SELECT * FROM ";
stemp.append(m_TableName);
stemp.append(" WHERE ");
stemp.append(skey);
try
{
/* iRet = sqlite3_prepare_v2(m_dbptr, stemp.c_str(), -1, &stmt, NULL);
sqlite3_finalize(stmt);
if (iRet != SQLITE_OK)
{
WriteLog("数据库 %s sql 语句 %s 语法错误",m_SqliteFileName,stemp.c_str());
return "{\"RETCODE\":-102,\"ERRORINFO\":\"SQL 语法错误\"}";
}
*/
iRet = sqlite3_get_table(m_dbptr, stemp.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
sqlite3_free_table(dbResult);
iFlag = 1;
WriteLog("数据库 %s sql 语句 %s 执行失败 errmsg %s",m_SqliteFileName.c_str(),stemp.c_str(),errmsg);
return "{\"RETCODE\":-7,\"ERRORINFO\":\"SQL 执行错误\"}";
}
if(0 == nRow)
{
sqlite3_free_table(dbResult);
// WriteLog("数据库 %s sql 语句 %s 查询 未找到",m_SqliteFileName,stemp.c_str());
iFlag = 1;
return "{\"RETCODE\":-8,\"ERRORINFO\":\"SQL 未找到记录\"}";
}
bFound = true;
/* if (!bFindAll)
{
sRecord = "{\"RETCODE\":1";
iRet = nColumn ;
for (int j = 0; j < nColumn; j++)
{
sRecord.append(",\"");
sRecord.append(dbResult[j]);
sRecord.append("\":\"");
sRecord.append(dbResult[iRet]);
sRecord.append("\"");
iRet++;
}
sRecord.append(",\"backup2\":\"");
sRecord.append(m_SqlVersion);
sRecord += "\"}";
sqlite3_free_table(dbResult);
iFlag = 1;
return sRecord;
}
*/
stemp = "";
sRecord = "{\"RETCODE\":1,\"DATA\":[";
for (int i = 0; i < nRow; i++)
{
if (0 == i)
{
stemp.append("{");
}
else
{
stemp.append(",{");
}
iRet = nColumn * (i + 1);
for (int j = 0; j < nColumn; j++)
{
if (j > 0)
{
stemp.append(",");
}
stemp.append("\"");
stemp.append(dbResult[j]);
stemp.append("\":\"");
if(dbResult[iRet])
{
stemp.append(dbResult[iRet]);
}
stemp.append("\"");
iRet++;
}
stemp.append(",\"backup2\":\"");
stemp.append(m_SqlVersion);
stemp.append("\"}");
}
sRecord.append(stemp);
sRecord.append("]}");
}
catch (...)
{
if (0 == iFlag)
{
sqlite3_free_table(dbResult);
}
WriteLog("数据库 %s sql 语句 %s 异常",m_SqliteFileName.c_str(),stemp.c_str());
sRecord = "{\"RETCODE\":-100,\"ERRORINFO\":\"异常跳出\"}";
return sRecord;
}
sqlite3_free_table(dbResult);
stemp ="";
iRet = Utf8ToGbk(stemp,sRecord);
if(iRet <0)
{
bFound = false;
stemp = "{\"RETCODE\":-101,\"ERRORINFO\":\"字符串转换失败\"}";
}
return stemp;
}
int mySqlite::GetWriteTime( const char * pName)
{
// HANDLE hdle;
// BOOL bRet;
WIN32_FIND_DATA ffd ;
HANDLE hFind = FindFirstFile(pName,&ffd);
if(INVALID_HANDLE_VALUE == hFind)
{
WriteLog("文件 %s 未找到",pName);
return -1;
}
m_WriteTime = ffd.ftLastWriteTime;
FindClose(hFind);
return 0;
}
string mySqlite::GetFileDate()
{
if(m_dbptr)
{
FILETIME localTime;
if (FileTimeToLocalFileTime(&m_WriteTime, &localTime))
{
SYSTEMTIME sysTime;
if (FileTimeToSystemTime(&localTime, &sysTime))
{
char strTime[50] = { 0 };
sprintf(strTime, "%04d-%02d-%02dT%02d:%02d:%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
return strTime;
}
}
}
return "2000-01-01T00:00:00";
}
/*
string mySqlite::GetFieldValueByName(const char * pFieldName)
{
if (!m_dbptr)
{
return "";
}
int iRet;
int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
//char buf[16];
string stemp;
iLen = strlen(pFieldName);
if (iLen > MAX_PRIKEYNAME_LEN)
{
return "";
}
stemp = "SELECT ";
stemp.append(pFieldName);
stemp.append(" FROM ");
stemp.append(SQL_IDXTAB_STR);
stemp.append(" LIMIT 1");
iRet = sqlite3_get_table(m_dbptr, stemp.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
sqlite3_free_table(dbResult);
return "";
}
if (0 != strcmp(dbResult[0], pFieldName))
{
sqlite3_free_table(dbResult);
return "";
}
stemp = dbResult[1];
sqlite3_free_table(dbResult);
//Close();
return stemp;
}
*/
int mySqlite::isnumer(char cChar,int base)
{
if(10 == base)
{
if ((cChar >= 0x30) && (cChar <= 0x39))
{
return 0;
}
else
{
return -1;
}
}
else if(16 == base)
{
if ((cChar >= 0x30) && (cChar <= 0x39))
{
return 0;
}
else if((cChar >= 0x41) && (cChar <= 0x46))
{
return 0;
}
else if((cChar >= 0x61) && (cChar <= 0x66))
{
return 0;
}
else
{
return -2;
}
}
return -2;
}
int mySqlite::isnumer(char * buf,int base)
{
int iLen;
int iRet;
iLen = strlen(buf);
if(0 == iLen)
{
return -1;
}
for(int i=0; i<iLen; i++)
{
iRet = isnumer(buf[i],base);
if(iRet <0)
{
return -2;
}
}
return 0;
}

@ -0,0 +1,896 @@
// mySqlite.cpp: implementation of the mySqlite class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "mySqlite.h"
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "WriteLog.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
mySqlite::mySqlite()
{
m_dbptr = NULL;
m_RecordCount = 0;
m_SqliteFileName = "";
m_SqlVersion = "";
memset(m_PriKey, 0, sizeof(m_PriKey));
}
mySqlite::~mySqlite()
{
}
int mySqlite::toWString(wstring &deststr,const string& sourcestr, unsigned int code)
{
std::wstring wstr;
int len;
int iret;
len = MultiByteToWideChar(code, 0, sourcestr.c_str(), -1, NULL, 0);
if (0 == len)
{
return -1;
}
wstr.resize(static_cast<size_t>(len + 1));
iret = MultiByteToWideChar(code, 0, sourcestr.c_str(), -1, const_cast<wchar_t*>(wstr.c_str()), len);
if (0 == len)
{
return -2;
}
deststr = wstr;
return 0;
}
int mySqlite::toYString(string& deststr,const std::wstring& sourcestr, unsigned int code )
{
string ystr;
int len;
int iret;
len = WideCharToMultiByte(code, 0, sourcestr.c_str(), -1, NULL, 0, NULL, NULL);
if (0 == len)
{
return -1;
}
ystr.resize(static_cast<size_t>(len - 1));
len = WideCharToMultiByte(code, 0, sourcestr.c_str(), -1, const_cast<char*>(ystr.c_str()), len, NULL, NULL);
if (0 == len)
{
return -2;
}
deststr = ystr;
}
int mySqlite::GbkToUtf8(string & utf8str, const string& gbkstr)
{
int iret;
wstring wstr;
string ystr;
iret = gbkstr.length();
if(iret <= 0)
{
return 0;
}
iret = toWString(wstr, gbkstr, CP_ACP);
if (iret < 0)
{
return -1;
}
iret = toYString(ystr, wstr);
if (iret < 0)
{
return -2;
}
utf8str = ystr;
return 0;
}
int mySqlite::Utf8ToGbk(string & gbkstr, const string& utf8str)
{
int iret;
wstring wstr;
string ystr;
iret = utf8str.length();
if (iret <= 0)
{
return 0;
}
iret = toWString(wstr, utf8str);
if (iret < 0)
{
return -1;
}
iret = toYString(ystr, wstr, CP_ACP);
if (iret < 0)
{
return -2;
}
gbkstr = ystr;
return 0;
}
bool mySqlite::Open(const char * pName, const char * pKey)
{
int iRet;
iRet = GetSqlTmpName(pName);
if (iRet < 0)
{
// WriteLog("文件 %s 获取时间失败, 返回值 %d",pName, iRet);
return false;
}
iRet = SetPriKey(pKey);
if (iRet < 0)
{
return false;
}
Close();
iRet = GetWriteTime(pName);
if (iRet < 0)
{
WriteLog("文件 %s 获取时间失败, 返回值 %d",pName, iRet);
return false;
}
iRet = sqlite3_open(pName, &m_dbptr);
if (iRet != SQLITE_OK)
{
sqlite3_close(m_dbptr);
m_dbptr = NULL;
WriteLog("文件 %s sqlite3_open失败",pName);
return false;
}
WriteLog("文件 %s 打开成功",pName);
m_SqliteFileName = pName;
iRet = GetTableName();
if(iRet < 0)
{
Close();
WriteLog("文件 %s 获取表名失败,返回值 %d",pName,iRet);
return false;
}
iRet = GetCountAndVerSion();
if(iRet < 0)
{
Close();
WriteLog("文件 %s 获取记录和版本失败,返回值 %d",pName,iRet);
return false;
}
return true;
}
void mySqlite::Close()
{
if (m_dbptr)
{
sqlite3_close(m_dbptr);
m_dbptr = NULL;
}
}
int mySqlite::SetPriKey(const char * pKey)
{
int iRet;
iRet = strlen(pKey);
if (iRet >= MAX_PRIKEYNAME_LEN)
{
WriteLog("key %s 长度太长",pKey);
return -1;
}
strcpy(m_PriKey, pKey);
return 0;
}
bool mySqlite::IsOpened()
{
if (m_dbptr)
{
return true;
}
return false;
}
string mySqlite::GetDBFFileName()
{
return m_SqliteFileName;
}
int mySqlite::GetSqlTmpName(const char * pName)
{
char buf[320];
// int iret;
int i;
int ilen;
char * ptr;
ilen = strlen(pName);
if(ilen >300)
{
WriteLog("文件名 %s 超过规定长度",pName);
return -1;
}
memset(buf,0,sizeof(buf));
strcpy(buf,pName);
for(i =ilen -1; i>=0; i--)
{
if(('\\' == buf[i]) || ('/' == buf[i]))
{
ptr = buf+i+1;
break;
}
}
ilen = strlen(ptr);
for(i =ilen -1; i>0; i--)
{
if('.' == ptr[i])
{
ptr[i] ='\0';
break;
}
}
ilen = strlen(ptr);
for(i =ilen -1; i>0; i--)
{
if('_' == ptr[i])
{
ptr[i] ='\0';
break;
}
}
m_SqliteTmpName = ptr;
return 0;
}
int mySqlite::GetTableName()
{
if (!m_dbptr)
{
return -1;
}
int iRet;
// int iFind;
int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
char * ptr;
// string stemp;
//char buf[16];
iRet = sqlite3_get_table(m_dbptr, SQL_GETTABLENAME_STR, &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK == iRet)
{ //查询成功
if(0 == nRow)
{
// WriteLog("数据库 %s sql 语句 %s 查询结果记录为0",m_SqliteFileName,SQL_GETTABLENAME_STR);
sqlite3_free_table(dbResult);
return -2;
}
if(nColumn != 1)
{
// WriteLog("数据库 %s sql 语句 %s 查询返回字段数不是1",m_SqliteFileName,SQL_GETTABLENAME_STR);
sqlite3_free_table(dbResult);
return -3;
}
int i;
for(i=0; i<nRow; i++)
{
ptr = dbResult[nColumn * (i + 1)];
if(0 == (strcmp(ptr,SQL_BLACKTAB_STR)))
{
m_TableName = SQL_BLACKTAB_STR;
sqlite3_free_table(dbResult);
return 0;
break;
}
}
for(i=0; i<nRow; i++)
{
ptr = dbResult[nColumn * (i + 1)];
iLen = strlen(ptr);
if(m_SqliteTmpName.length() == iLen)
{
if(0 == (strnicmp(ptr,m_SqliteTmpName.c_str(), iLen)))
{
m_TableName = ptr;
sqlite3_free_table(dbResult);
return 0;
break;
}
}
}
// WriteLog("数据库 %s 未找到符合条件的表",m_SqliteFileName);
sqlite3_free_table(dbResult);
return -5;
}
else
{
WriteLog("数据库 %s sql 语句 %s 查询失败",m_SqliteFileName.c_str(),SQL_GETTABLENAME_STR);
sqlite3_free_table(dbResult);
return -6;
}
//Close();
sqlite3_free_table(dbResult);
return 0;
}
int mySqlite::GetCountAndVerSion()
{
if (!m_dbptr)
{
return -1;
}
int iRet;
int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
//char buf[16];s'q
iRet = sqlite3_get_table(m_dbptr, SQL_GETCOUNTANDVER_STR, &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK == iRet)
{ //查询成功
if(0 == nRow)
{
//WriteLog("数据库 %s sql 语句 %s 查询结果记录为0",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -2;
}
if(nColumn != 2)
{
//WriteLog("数据库 %s sql 语句 %s 查询返回字段数不是2",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -3;
}
iLen = strlen(dbResult[0]);
if(iLen >128)
{
// WriteLog("数据库 %s sql 语句 %s 查询 版本太长",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -4;
}
m_SqlVersion = dbResult[2];
iLen = strlen(dbResult[3]);
if (iLen > 10)
{
//Close();
//WriteLog("数据库 %s sql 语句 %s 查询记录数 太长",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -5;
}
iRet = isnumer(dbResult[3]);
if(iRet <0)
{
//WriteLog("数据库 %s sql 语句 %s 查询记录数 不是数字",m_SqliteFileName,SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -6;
}
m_RecordCount = atoi(dbResult[3]);
}
else
{
WriteLog("数据库 %s sql 语句 %s 查询失败",m_SqliteFileName.c_str(),SQL_GETCOUNTANDVER_STR);
sqlite3_free_table(dbResult);
return -7;
}
WriteLog("数据库 %s m_SqlVersion %s m_RecordCount %d",m_SqliteFileName.c_str(),m_SqlVersion.c_str(),m_RecordCount);
//Close();
sqlite3_free_table(dbResult);
return 0;
}
int mySqlite::GetRecordCount()
{
return m_RecordCount;
}
string mySqlite::GetSqlVersion()
{
return m_SqlVersion;
}
string mySqlite::SqlFind(const char *KeyValue, bool &bFound, const bool bFindAll)
{
if (!m_dbptr)
{
bFound = false;
return "{\"RETCODE\":-5,\"ERRORINFO\":\"SQL文件未打开\"}";
}
int iRet;
// int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
string stemp,sRecord,skey;
int iFlag = 0;
//char buf[16];
bFound = false;
iRet = strlen(KeyValue);
if (iRet > MAX_PRIKEYVALUE_LEN)
{
return "{\"RETCODE\":-6,\"ERRORINFO\":\"主键字符串太长\"}";
}
try
{
iRet = GbkToUtf8(skey,KeyValue);
if(iRet <0)
{
return "{\"RETCODE\":-104,\"ERRORINFO\":\"字符串转utf8 失败\"}";
}
stemp = "SELECT * FROM ";
stemp.append(m_TableName);
stemp.append(" WHERE ");
stemp.append(m_PriKey);
stemp.append("='");
stemp.append(skey);
stemp.append("'");
iRet = sqlite3_get_table(m_dbptr, stemp.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
sqlite3_free_table(dbResult);
iFlag = 1;
// WriteLog("数据库 %s sql 语句 %s 查询失败",m_SqliteFileName,stemp.c_str());
return "{\"RETCODE\":-7,\"ERRORINFO\":\"SQL 执行错误\"}";
}
if(0 == nRow)
{
sqlite3_free_table(dbResult);
// WriteLog("数据库 %s sql 语句 %s 查询 未找到",m_SqliteFileName,stemp.c_str());
iFlag = 1;
return "{\"RETCODE\":-8,\"ERRORINFO\":\"SQL 未找到记录\"}";
}
bFound = true;
if (!bFindAll)
{
sRecord = "{\"RETCODE\":1";
iRet = nColumn ;
for (int j = 0; j < nColumn; j++)
{
sRecord.append(",\"");
sRecord.append(dbResult[j]);
sRecord.append("\":\"");
if(dbResult[iRet])
{
sRecord.append(dbResult[iRet]);
}
sRecord.append("\"");
iRet++;
}
sRecord.append(",\"backup2\":\"");
sRecord.append(m_SqlVersion);
sRecord += "\"}";
sqlite3_free_table(dbResult);
iFlag = 1;
stemp ="";
iRet = Utf8ToGbk(stemp,sRecord);
if(iRet <0)
{
bFound = false;
stemp = "{\"RETCODE\":-101,\"ERRORINFO\":\"字符串转换失败\"}";
}
return stemp;
}
stemp = "";
sRecord = "{\"RETCODE\":1,\"DATA\":[";
for (int i = 0; i < nRow; i++)
{
if (0 == i)
{
stemp.append("{");
}
else
{
stemp.append(",{");
}
iRet = nColumn * (i + 1);
for (int j = 0; j < nColumn; j++)
{
if (j > 0)
{
stemp.append(",");
}
stemp.append("\"");
stemp.append(dbResult[j]);
stemp.append("\":\"");
if(dbResult[iRet])
{
stemp.append(dbResult[iRet]);
}
stemp.append("\"");
iRet++;
}
stemp.append(",\"backup2\":\"");
stemp.append(m_SqlVersion);
stemp.append("\"}");
}
sRecord.append(stemp);
sRecord.append("]}");
}
catch (...)
{
if (0 == iFlag)
{
sqlite3_free_table(dbResult);
}
sRecord = "{\"RETCODE\":-100,\"ERRORINFO\":\"异常跳出\"}";
return sRecord;
}
sqlite3_free_table(dbResult);
stemp ="";
iRet = Utf8ToGbk(stemp,sRecord);
if(iRet <0)
{
bFound = false;
stemp = "{\"RETCODE\":-101,\"ERRORINFO\":\"字符串转换失败\"}";
}
return stemp;
}
string mySqlite::FinDWhere(const char *pWhere, bool &bFound)
{
if (!m_dbptr)
{
bFound = false;
return "{\"RETCODE\":-5,\"ERRORINFO\":\"SQL文件未打开\"}";
}
int iRet;
// int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
string stemp,sRecord,skey;
int iFlag = 0;
//char buf[16];
bFound = false;
try
{
iRet = GbkToUtf8(skey,pWhere);
if(iRet <0)
{
return "{\"RETCODE\":-104,\"ERRORINFO\":\"字符串转utf8 失败\"}";
}
stemp = "SELECT * FROM ";
stemp.append(m_TableName);
stemp.append(" WHERE ");
stemp.append(skey);
iRet = sqlite3_get_table(m_dbptr, stemp.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
sqlite3_free_table(dbResult);
iFlag = 1;
// WriteLog("数据库 %s sql 语句 %s 查询失败",m_SqliteFileName,stemp.c_str());
return "{\"RETCODE\":-7,\"ERRORINFO\":\"SQL 执行错误\"}";
}
if(0 == nRow)
{
sqlite3_free_table(dbResult);
// WriteLog("数据库 %s sql 语句 %s 查询 未找到",m_SqliteFileName,stemp.c_str());
iFlag = 1;
return "{\"RETCODE\":-8,\"ERRORINFO\":\"SQL 未找到记录\"}";
}
bFound = true;
/* if (!bFindAll)
{
sRecord = "{\"RETCODE\":1";
iRet = nColumn ;
for (int j = 0; j < nColumn; j++)
{
sRecord.append(",\"");
sRecord.append(dbResult[j]);
sRecord.append("\":\"");
sRecord.append(dbResult[iRet]);
sRecord.append("\"");
iRet++;
}
sRecord.append(",\"backup2\":\"");
sRecord.append(m_SqlVersion);
sRecord += "\"}";
sqlite3_free_table(dbResult);
iFlag = 1;
return sRecord;
}
*/
stemp = "";
sRecord = "{\"RETCODE\":1,\"DATA\":[";
for (int i = 0; i < nRow; i++)
{
if (0 == i)
{
stemp.append("{");
}
else
{
stemp.append(",{");
}
iRet = nColumn * (i + 1);
for (int j = 0; j < nColumn; j++)
{
if (j > 0)
{
stemp.append(",");
}
stemp.append("\"");
stemp.append(dbResult[j]);
stemp.append("\":\"");
if(dbResult[iRet])
{
stemp.append(dbResult[iRet]);
}
stemp.append("\"");
iRet++;
}
stemp.append(",\"backup2\":\"");
stemp.append(m_SqlVersion);
stemp.append("\"}");
}
sRecord.append(stemp);
sRecord.append("]}");
}
catch (...)
{
if (0 == iFlag)
{
sqlite3_free_table(dbResult);
}
sRecord = "{\"RETCODE\":-100,\"ERRORINFO\":\"异常跳出\"}";
return sRecord;
}
sqlite3_free_table(dbResult);
stemp ="";
iRet = Utf8ToGbk(stemp,sRecord);
if(iRet <0)
{
bFound = false;
stemp = "{\"RETCODE\":-101,\"ERRORINFO\":\"字符串转换失败\"}";
}
return stemp;
}
int mySqlite::GetWriteTime( const char * pName)
{
// HANDLE hdle;
// BOOL bRet;
WIN32_FIND_DATA ffd ;
HANDLE hFind = FindFirstFile(pName,&ffd);
if(INVALID_HANDLE_VALUE == hFind)
{
WriteLog("文件 %s 未找到",pName);
return -1;
}
m_WriteTime = ffd.ftLastWriteTime;
FindClose(hFind);
return 0;
}
string mySqlite::GetFileDate()
{
if(m_dbptr)
{
FILETIME localTime;
if (FileTimeToLocalFileTime(&m_WriteTime, &localTime))
{
SYSTEMTIME sysTime;
if (FileTimeToSystemTime(&localTime, &sysTime))
{
char strTime[50] = { 0 };
sprintf(strTime, "%04d-%02d-%02dT%02d:%02d:%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
return strTime;
}
}
}
return "2000-01-01T00:00:00";
}
string mySqlite::GetFieldValueByName(const char * pFieldName)
{
if (!m_dbptr)
{
return "";
}
int iRet;
int iLen;
char * errmsg = NULL;
char **dbResult; //是 char ** 类型,两个*号
int nRow, nColumn;
//char buf[16];
string stemp;
iLen = strlen(pFieldName);
if (iLen > MAX_PRIKEYNAME_LEN)
{
return "";
}
stemp = "SELECT ";
stemp.append(pFieldName);
stemp.append(" FROM ");
stemp.append(SQL_IDXTAB_STR);
stemp.append(" LIMIT 1");
iRet = sqlite3_get_table(m_dbptr, stemp.c_str(), &dbResult, &nRow, &nColumn, &errmsg);
if (SQLITE_OK != iRet)
{
sqlite3_free_table(dbResult);
return "";
}
if (0 != strcmp(dbResult[0], pFieldName))
{
sqlite3_free_table(dbResult);
return "";
}
stemp = dbResult[1];
sqlite3_free_table(dbResult);
//Close();
return stemp;
}
int mySqlite::isnumer(char cChar,int base)
{
if(10 == base)
{
if ((cChar >= 0x30) && (cChar <= 0x39))
{
return 0;
}
else
{
return -1;
}
}
else if(16 == base)
{
if ((cChar >= 0x30) && (cChar <= 0x39))
{
return 0;
}
else if((cChar >= 0x41) && (cChar <= 0x46))
{
return 0;
}
else if((cChar >= 0x61) && (cChar <= 0x66))
{
return 0;
}
else
{
return -2;
}
}
return -2;
}
int mySqlite::isnumer(char * buf,int base)
{
int iLen;
int iRet;
iLen = strlen(buf);
if(0 == iLen)
{
return -1;
}
for(int i=0; i<iLen; i++)
{
iRet = isnumer(buf[i],base);
if(iRet <0)
{
return -2;
}
}
return 0;
}

@ -0,0 +1,79 @@
// mySqlite.h: interface for the mySqlite class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MYSQLITE_H__F17831F1_9B4D_4DB9_9AE6_A1D77CCEC173__INCLUDED_)
#define AFX_MYSQLITE_H__F17831F1_9B4D_4DB9_9AE6_A1D77CCEC173__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define MAX_PRIKEYNAME_LEN 128
#define MAX_PRIKEYVALUE_LEN 8192
#define MAX_RECCOUNT_LEN 20
#define SQL_BLACKTAB_STR "BLACK_TABLE"
#define SQL_IDXTAB_STR "IDX_TABLE"
//#define SQL_GETCOUNT_STR "SELECT COUNT(*) FROM BLACK_TABLE"
#define SQL_GETCOUNTANDVER_STR "SELECT VERSION, RECCOUNT FROM IDX_TABLE LIMIT 1"
#define SQL_GETTABLENAME_STR "SELECT NAME FROM sqlite_master where type='table' ORDER by name"
//#define SQL_GETVERSION_STR "SELECT * FROM BLACK_TABLE limit 1"
#include "sqlite3.h"
#include <string>
using namespace std;
class mySqlite
{
public:
mySqlite();
virtual ~mySqlite();
public:
bool Open(const char * pName,const char * pKey);
void Close();
bool IsOpened();
int GetRecordCount();
string SqlFind(const char *KeyValue, bool &bFound, const bool bFindAll);
string FindWhere(const char *pWhere, bool &bFound);
// string GetFieldValueByName(const char * pFieldName);
string GetFileDate();
string GetDBFFileName();
string GetSqlVersion();
private:
int SetPriKey(const char * pKey);
int GetTableName();
int GetSqlTmpName(const char * pName);
int GetCountAndVerSion();
int GetWriteTime(const char * pName);
int isnumer(char cChar,int base =10);
int isnumer(char * buf,int base =10);
//ת»»º¯Êý
int toWString(wstring &deststr,const string& sourcestr, unsigned int code = CP_UTF8);
int toYString(string& deststr,const std::wstring& sourcestr, unsigned int code = CP_UTF8);
int GbkToUtf8(string & utf8str, const string& gbkstr);
int Utf8ToGbk(string & gbkstr, const string& utf8str);
private:
sqlite3 * m_dbptr;
int m_RecordCount;
FILETIME m_WriteTime;
int m_IdxFlag;
char m_PriKey[MAX_PRIKEYNAME_LEN];
string m_TableName;
string m_SqliteFileName;
string m_SqlVersion;
string m_SqliteTmpName;
};
#endif // !defined(AFX_MYSQLITE_H__F17831F1_9B4D_4DB9_9AE6_A1D77CCEC173__INCLUDED_)

@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Script1.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

@ -0,0 +1,331 @@
EXPORTS
sqlite3_aggregate_context
sqlite3_aggregate_count
sqlite3_auto_extension
sqlite3_autovacuum_pages
sqlite3_backup_finish
sqlite3_backup_init
sqlite3_backup_pagecount
sqlite3_backup_remaining
sqlite3_backup_step
sqlite3_bind_blob
sqlite3_bind_blob64
sqlite3_bind_double
sqlite3_bind_int
sqlite3_bind_int64
sqlite3_bind_null
sqlite3_bind_parameter_count
sqlite3_bind_parameter_index
sqlite3_bind_parameter_name
sqlite3_bind_pointer
sqlite3_bind_text
sqlite3_bind_text16
sqlite3_bind_text64
sqlite3_bind_value
sqlite3_bind_zeroblob
sqlite3_bind_zeroblob64
sqlite3_blob_bytes
sqlite3_blob_close
sqlite3_blob_open
sqlite3_blob_read
sqlite3_blob_reopen
sqlite3_blob_write
sqlite3_busy_handler
sqlite3_busy_timeout
sqlite3_cancel_auto_extension
sqlite3changegroup_add
sqlite3changegroup_add_strm
sqlite3changegroup_delete
sqlite3changegroup_new
sqlite3changegroup_output
sqlite3changegroup_output_strm
sqlite3_changes
sqlite3_changes64
sqlite3changeset_apply
sqlite3changeset_apply_strm
sqlite3changeset_apply_v2
sqlite3changeset_apply_v2_strm
sqlite3changeset_concat
sqlite3changeset_concat_strm
sqlite3changeset_conflict
sqlite3changeset_finalize
sqlite3changeset_fk_conflicts
sqlite3changeset_invert
sqlite3changeset_invert_strm
sqlite3changeset_new
sqlite3changeset_next
sqlite3changeset_old
sqlite3changeset_op
sqlite3changeset_pk
sqlite3changeset_start
sqlite3changeset_start_strm
sqlite3changeset_start_v2
sqlite3changeset_start_v2_strm
sqlite3_clear_bindings
sqlite3_close
sqlite3_close_v2
sqlite3_collation_needed
sqlite3_collation_needed16
sqlite3_column_blob
sqlite3_column_bytes
sqlite3_column_bytes16
sqlite3_column_count
sqlite3_column_database_name
sqlite3_column_database_name16
sqlite3_column_decltype
sqlite3_column_decltype16
sqlite3_column_double
sqlite3_column_int
sqlite3_column_int64
sqlite3_column_name
sqlite3_column_name16
sqlite3_column_origin_name
sqlite3_column_origin_name16
sqlite3_column_table_name
sqlite3_column_table_name16
sqlite3_column_text
sqlite3_column_text16
sqlite3_column_type
sqlite3_column_value
sqlite3_commit_hook
sqlite3_compileoption_get
sqlite3_compileoption_used
sqlite3_complete
sqlite3_complete16
sqlite3_config
sqlite3_context_db_handle
sqlite3_create_collation
sqlite3_create_collation16
sqlite3_create_collation_v2
sqlite3_create_filename
sqlite3_create_function
sqlite3_create_function16
sqlite3_create_function_v2
sqlite3_create_module
sqlite3_create_module_v2
sqlite3_create_window_function
sqlite3_database_file_object
sqlite3_data_count
sqlite3_db_cacheflush
sqlite3_db_config
sqlite3_db_filename
sqlite3_db_handle
sqlite3_db_mutex
sqlite3_db_readonly
sqlite3_db_release_memory
sqlite3_db_status
sqlite3_declare_vtab
sqlite3_deserialize
sqlite3_drop_modules
sqlite3_enable_load_extension
sqlite3_enable_shared_cache
sqlite3_errcode
sqlite3_errmsg
sqlite3_errmsg16
sqlite3_errstr
sqlite3_exec
sqlite3_expanded_sql
sqlite3_expired
sqlite3_extended_errcode
sqlite3_extended_result_codes
sqlite3_file_control
sqlite3_filename_database
sqlite3_filename_journal
sqlite3_filename_wal
sqlite3_finalize
sqlite3_free
sqlite3_free_filename
sqlite3_free_table
sqlite3_get_autocommit
sqlite3_get_auxdata
sqlite3_get_table
sqlite3_global_recover
sqlite3_hard_heap_limit64
sqlite3_initialize
sqlite3_interrupt
sqlite3_keyword_check
sqlite3_keyword_count
sqlite3_keyword_name
sqlite3_last_insert_rowid
sqlite3_libversion
sqlite3_libversion_number
sqlite3_limit
sqlite3_load_extension
sqlite3_log
sqlite3_malloc
sqlite3_malloc64
sqlite3_memory_alarm
sqlite3_memory_highwater
sqlite3_memory_used
sqlite3_mprintf
sqlite3_msize
sqlite3_mutex_alloc
sqlite3_mutex_enter
sqlite3_mutex_free
sqlite3_mutex_leave
sqlite3_mutex_try
sqlite3_next_stmt
sqlite3_open
sqlite3_open16
sqlite3_open_v2
sqlite3_os_end
sqlite3_os_init
sqlite3_overload_function
sqlite3_prepare
sqlite3_prepare16
sqlite3_prepare16_v2
sqlite3_prepare16_v3
sqlite3_prepare_v2
sqlite3_prepare_v3
sqlite3_preupdate_blobwrite
sqlite3_preupdate_count
sqlite3_preupdate_depth
sqlite3_preupdate_hook
sqlite3_preupdate_new
sqlite3_preupdate_old
sqlite3_profile
sqlite3_progress_handler
sqlite3_randomness
sqlite3_realloc
sqlite3_realloc64
sqlite3rebaser_configure
sqlite3rebaser_create
sqlite3rebaser_delete
sqlite3rebaser_rebase
sqlite3rebaser_rebase_strm
sqlite3_release_memory
sqlite3_reset
sqlite3_reset_auto_extension
sqlite3_result_blob
sqlite3_result_blob64
sqlite3_result_double
sqlite3_result_error
sqlite3_result_error16
sqlite3_result_error_code
sqlite3_result_error_nomem
sqlite3_result_error_toobig
sqlite3_result_int
sqlite3_result_int64
sqlite3_result_null
sqlite3_result_pointer
sqlite3_result_subtype
sqlite3_result_text
sqlite3_result_text16
sqlite3_result_text16be
sqlite3_result_text16le
sqlite3_result_text64
sqlite3_result_value
sqlite3_result_zeroblob
sqlite3_result_zeroblob64
sqlite3_rollback_hook
sqlite3_rtree_geometry_callback
sqlite3_rtree_query_callback
sqlite3_serialize
sqlite3session_attach
sqlite3session_changeset
sqlite3session_changeset_size
sqlite3session_changeset_strm
sqlite3session_config
sqlite3session_create
sqlite3session_delete
sqlite3session_diff
sqlite3session_enable
sqlite3session_indirect
sqlite3session_isempty
sqlite3session_memory_used
sqlite3session_object_config
sqlite3session_patchset
sqlite3session_patchset_strm
sqlite3session_table_filter
sqlite3_set_authorizer
sqlite3_set_auxdata
sqlite3_set_last_insert_rowid
sqlite3_shutdown
sqlite3_sleep
sqlite3_snprintf
sqlite3_soft_heap_limit
sqlite3_soft_heap_limit64
sqlite3_sourceid
sqlite3_sql
sqlite3_status
sqlite3_status64
sqlite3_step
sqlite3_stmt_busy
sqlite3_stmt_isexplain
sqlite3_stmt_readonly
sqlite3_stmt_status
sqlite3_str_append
sqlite3_str_appendall
sqlite3_str_appendchar
sqlite3_str_appendf
sqlite3_str_errcode
sqlite3_str_finish
sqlite3_strglob
sqlite3_stricmp
sqlite3_str_length
sqlite3_strlike
sqlite3_str_new
sqlite3_strnicmp
sqlite3_str_reset
sqlite3_str_value
sqlite3_str_vappendf
sqlite3_system_errno
sqlite3_table_column_metadata
sqlite3_test_control
sqlite3_thread_cleanup
sqlite3_threadsafe
sqlite3_total_changes
sqlite3_total_changes64
sqlite3_trace
sqlite3_trace_v2
sqlite3_transfer_bindings
sqlite3_txn_state
sqlite3_update_hook
sqlite3_uri_boolean
sqlite3_uri_int64
sqlite3_uri_key
sqlite3_uri_parameter
sqlite3_user_data
sqlite3_value_blob
sqlite3_value_bytes
sqlite3_value_bytes16
sqlite3_value_double
sqlite3_value_dup
sqlite3_value_free
sqlite3_value_frombind
sqlite3_value_int
sqlite3_value_int64
sqlite3_value_nochange
sqlite3_value_numeric_type
sqlite3_value_pointer
sqlite3_value_subtype
sqlite3_value_text
sqlite3_value_text16
sqlite3_value_text16be
sqlite3_value_text16le
sqlite3_value_type
sqlite3_vfs_find
sqlite3_vfs_register
sqlite3_vfs_unregister
sqlite3_vmprintf
sqlite3_vsnprintf
sqlite3_vtab_collation
sqlite3_vtab_config
sqlite3_vtab_nochange
sqlite3_vtab_on_conflict
sqlite3_wal_autocheckpoint
sqlite3_wal_checkpoint
sqlite3_wal_checkpoint_v2
sqlite3_wal_hook
sqlite3_win32_is_nt
sqlite3_win32_mbcs_to_utf8
sqlite3_win32_mbcs_to_utf8_v2
sqlite3_win32_set_directory
sqlite3_win32_set_directory16
sqlite3_win32_set_directory8
sqlite3_win32_sleep
sqlite3_win32_unicode_to_utf8
sqlite3_win32_utf8_to_mbcs
sqlite3_win32_utf8_to_mbcs_v2
sqlite3_win32_utf8_to_unicode
sqlite3_win32_write_debug

File diff suppressed because it is too large Load Diff

@ -0,0 +1,97 @@
; CLW file contains information for the MFC ClassWizard
[General Info]
Version=1
LastClass=CBlackFinderTestDlg
LastTemplate=CDialog
NewFileInclude1=#include "stdafx.h"
NewFileInclude2=#include "BlackFinderTest.h"
ClassCount=3
Class1=CBlackFinderTestApp
Class2=CBlackFinderTestDlg
Class3=CAboutDlg
ResourceCount=3
Resource1=IDD_ABOUTBOX
Resource2=IDR_MAINFRAME
Resource3=IDD_BLACKFINDERTEST_DIALOG
[CLS:CBlackFinderTestApp]
Type=0
HeaderFile=BlackFinderTest.h
ImplementationFile=BlackFinderTest.cpp
Filter=N
[CLS:CBlackFinderTestDlg]
Type=0
HeaderFile=BlackFinderTestDlg.h
ImplementationFile=BlackFinderTestDlg.cpp
Filter=D
BaseClass=CDialog
VirtualFilter=dWC
LastObject=CBlackFinderTestDlg
[CLS:CAboutDlg]
Type=0
HeaderFile=BlackFinderTestDlg.h
ImplementationFile=BlackFinderTestDlg.cpp
Filter=D
[DLG:IDD_ABOUTBOX]
Type=1
Class=CAboutDlg
ControlCount=4
Control1=IDC_STATIC,static,1342177283
Control2=IDC_STATIC,static,1342308480
Control3=IDC_STATIC,static,1342308352
Control4=IDOK,button,1342373889
[DLG:IDD_BLACKFINDERTEST_DIALOG]
Type=1
Class=CBlackFinderTestDlg
ControlCount=43
Control1=IDC_EDITINFO,edit,1350631556
Control2=IDC_BUTTONCREATE,button,1342242816
Control3=IDC_BUTTONLOAD,button,1342242816
Control4=IDC_BUTTONLOADBACK,button,1342242816
Control5=IDC_BUTTONFIND,button,1342242816
Control6=IDC_EDITCARDID,edit,1350631552
Control7=IDC_BUTTONVERSION,button,1342242816
Control8=IDC_BUTTONTIMELOAD,button,1342242816
Control9=IDC_EDIT_DBFNAME,edit,1350631552
Control10=IDC_BTN_FIND2,button,1342242816
Control11=IDC_BUTTONFINDSQL,button,1342242816
Control12=IDC_EDITSQLID,edit,1350631552
Control13=IDC_BTN_FINDSQL2,button,1342242816
Control14=IDC_BUTTONLOADBACKSQL,button,1342242816
Control15=IDC_BUTTONVERSIONSQL,button,1342242816
Control16=IDC_BUTTONLOADSQL,button,1342242816
Control17=IDC_EDIT_SQLNAME,edit,1350631552
Control18=IDC_BUTTONCREATESQL,button,1073807360
Control19=IDC_BUTTONSQL,button,1342242816
Control20=IDC_BUTTONFINDSQ3,button,1342242816
Control21=IDC_EDITSQLWHERE,edit,1350631552
Control22=IDC_BUTTONSQL2,button,1342242816
Control23=IDC_BUTTONFINDSQL2,button,1342242816
Control24=IDC_EDITSQLID2,edit,1350631552
Control25=IDC_BTN_FINDSQL3,button,1342242816
Control26=IDC_BUTTONLOADBACKSQL2,button,1342242816
Control27=IDC_BUTTONVERSIONSQL2,button,1342242816
Control28=IDC_BUTTONLOADSQL2,button,1342242816
Control29=IDC_EDIT_SQLNAME2,edit,1350631552
Control30=IDC_BUTTONFINDSQ4,button,1342242816
Control31=IDC_EDITSQLWHERE2,edit,1350631552
Control32=IDC_STATIC,static,1342308352
Control33=IDC_EDITPRIKEY,edit,1350631552
Control34=IDC_STATIC,static,1342308352
Control35=IDC_EDITPRIKEY2,edit,1350631552
Control36=IDC_EDITLOAD_BACK,edit,1350631552
Control37=IDC_EDITLOAD_BACK2,edit,1350631552
Control38=IDC_STATIC,static,1342308352
Control39=IDC_STATIC,static,1342308352
Control40=IDC_STATIC,static,1342308352
Control41=IDC_STATIC,static,1342308352
Control42=IDC_STATIC,static,1342308352
Control43=IDC_STATIC,static,1342308352

@ -0,0 +1,74 @@
// BlackFinderTest.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "BlackFinderTest.h"
#include "BlackFinderTestDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBlackFinderTestApp
BEGIN_MESSAGE_MAP(CBlackFinderTestApp, CWinApp)
//{{AFX_MSG_MAP(CBlackFinderTestApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBlackFinderTestApp construction
CBlackFinderTestApp::CBlackFinderTestApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CBlackFinderTestApp object
CBlackFinderTestApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CBlackFinderTestApp initialization
BOOL CBlackFinderTestApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CBlackFinderTestDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}

@ -0,0 +1,147 @@
# Microsoft Developer Studio Project File - Name="BlackFinderTest" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=BlackFinderTest - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "BlackFinderTest.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "BlackFinderTest.mak" CFG="BlackFinderTest - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "BlackFinderTest - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "BlackFinderTest - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "BlackFinderTest - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x804 /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "BlackFinderTest - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x804 /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 BlackFinder.lib /nologo /subsystem:windows /debug /machine:I386 /out:"F:/test/BlackFinderTest/Debug/BlackFinderTest.exe" /pdbtype:sept
!ENDIF
# Begin Target
# Name "BlackFinderTest - Win32 Release"
# Name "BlackFinderTest - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\BlackFinderTest.cpp
# End Source File
# Begin Source File
SOURCE=.\BlackFinderTest.rc
# End Source File
# Begin Source File
SOURCE=.\BlackFinderTestDlg.cpp
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\BlackFinderTest.h
# End Source File
# Begin Source File
SOURCE=.\BlackFinderTestDlg.h
# End Source File
# Begin Source File
SOURCE=.\Resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\res\BlackFinderTest.ico
# End Source File
# Begin Source File
SOURCE=.\res\BlackFinderTest.rc2
# End Source File
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "BlackFinderTest"=.\BlackFinderTest.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

@ -0,0 +1,49 @@
// BlackFinderTest.h : main header file for the BLACKFINDERTEST application
//
#if !defined(AFX_BLACKFINDERTEST_H__8B06D0BE_79CD_4592_9A9F_6ADCA12A7959__INCLUDED_)
#define AFX_BLACKFINDERTEST_H__8B06D0BE_79CD_4592_9A9F_6ADCA12A7959__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CBlackFinderTestApp:
// See BlackFinderTest.cpp for the implementation of this class
//
class CBlackFinderTestApp : public CWinApp
{
public:
CBlackFinderTestApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBlackFinderTestApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CBlackFinderTestApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BLACKFINDERTEST_H__8B06D0BE_79CD_4592_9A9F_6ADCA12A7959__INCLUDED_)

@ -0,0 +1,16 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: BlackFinderTest - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
<h3>Results</h3>
BlackFinderTest.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>

@ -0,0 +1,246 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Chinese (P.R.C.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
#pragma code_page(936)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 4, 2\r\n"
"#pragma code_page(936)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\BlackFinderTest.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""l.chs\\afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\BlackFinderTest.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "关于 BlackFinderTest"
FONT 9, "宋体"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "BlackFinderTest 1.0 版",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "版权所有 (C) 2023",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "确定",IDOK,178,7,50,14,WS_GROUP
END
IDD_BLACKFINDERTEST_DIALOG DIALOGEX 0, 0, 705, 312
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "BlackFinderTest"
FONT 9, "宋体"
BEGIN
EDITTEXT IDC_EDITINFO,14,7,183,242,ES_MULTILINE | ES_AUTOHSCROLL
PUSHBUTTON "创建DBF",IDC_BUTTONCREATE,244,49,50,14
PUSHBUTTON "加载DBF",IDC_BUTTONLOAD,244,77,50,14
PUSHBUTTON "后台加载DBF",IDC_BUTTONLOADBACK,222,187,50,14
PUSHBUTTON "查找DBF",IDC_BUTTONFIND,254,121,50,14
EDITTEXT IDC_EDITCARDID,221,142,95,15,ES_AUTOHSCROLL
PUSHBUTTON "DBF版本",IDC_BUTTONVERSION,222,211,50,14
PUSHBUTTON "定时加载",IDC_BUTTONTIMELOAD,222,235,50,14
EDITTEXT IDC_EDIT_DBFNAME,205,95,127,17,ES_AUTOHSCROLL
PUSHBUTTON "查找DBF2",IDC_BTN_FIND2,222,163,50,14
PUSHBUTTON "查找SQL",IDC_BUTTONFINDSQL,409,121,50,14
EDITTEXT IDC_EDITSQLID,390,144,95,15,ES_AUTOHSCROLL
PUSHBUTTON "查找SQL2",IDC_BTN_FINDSQL2,393,164,50,14
PUSHBUTTON "后台加载SQL",IDC_BUTTONLOADBACKSQL,393,229,50,14
PUSHBUTTON "SQL版本",IDC_BUTTONVERSIONSQL,394,283,50,14
PUSHBUTTON "加载SQL",IDC_BUTTONLOADSQL,405,41,50,14
EDITTEXT IDC_EDIT_SQLNAME,362,71,127,17,ES_AUTOHSCROLL
PUSHBUTTON "创建SQL",IDC_BUTTONCREATESQL,369,15,6,6,NOT WS_VISIBLE
PUSHBUTTON "创建sql",IDC_BUTTONSQL,403,24,50,14
PUSHBUTTON "查找SQL3",IDC_BUTTONFINDSQ3,392,185,50,14
EDITTEXT IDC_EDITSQLWHERE,336,203,146,17,ES_AUTOHSCROLL
PUSHBUTTON "创建sqlnext",IDC_BUTTONSQL2,547,24,50,14
PUSHBUTTON "查找SQLnext",IDC_BUTTONFINDSQL2,555,121,50,14
EDITTEXT IDC_EDITSQLID2,536,144,95,15,ES_AUTOHSCROLL
PUSHBUTTON "查找SQL2next",IDC_BTN_FINDSQL3,539,164,59,14
PUSHBUTTON "后台加载SQLnext",IDC_BUTTONLOADBACKSQL2,539,229,64,14
PUSHBUTTON "SQL版本next",IDC_BUTTONVERSIONSQL2,539,283,65,14
PUSHBUTTON "加载SQLnext",IDC_BUTTONLOADSQL2,547,41,50,14
EDITTEXT IDC_EDIT_SQLNAME2,550,72,127,17,ES_AUTOHSCROLL
PUSHBUTTON "查找SQL3next",IDC_BUTTONFINDSQ4,538,185,59,14
EDITTEXT IDC_EDITSQLWHERE2,499,204,146,17,ES_AUTOHSCROLL
LTEXT "主键",IDC_STATIC,348,101,25,14
EDITTEXT IDC_EDITPRIKEY,383,97,79,16,ES_AUTOHSCROLL
LTEXT "主键",IDC_STATIC,489,99,25,14
EDITTEXT IDC_EDITPRIKEY2,525,95,79,16,ES_AUTOHSCROLL
EDITTEXT IDC_EDITLOAD_BACK,335,250,124,18,ES_AUTOHSCROLL
EDITTEXT IDC_EDITLOAD_BACK2,514,250,124,18,ES_AUTOHSCROLL
LTEXT "键值",IDC_STATIC,349,145,22,15
LTEXT "键值",IDC_STATIC,505,145,22,15
LTEXT "数据库名",IDC_STATIC,504,73,38,14
LTEXT "数据库名",IDC_STATIC,315,72,38,14
LTEXT "数据库名",IDC_STATIC,287,252,38,14
LTEXT "数据库名",IDC_STATIC,471,252,38,14
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "BlackFinderTest Microsoft 基础类应用程序\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "BlackFinderTest\0"
VALUE "LegalCopyright", "版权所有 (C) 2023\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "BlackFinderTest.EXE\0"
VALUE "ProductName", "BlackFinderTest 应用程序\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 228
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_BLACKFINDERTEST_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 698
TOPMARGIN, 7
BOTTOMMARGIN, 305
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_ABOUTBOX "关于 BlackFinderTest(&A)..."
END
#endif // Chinese (P.R.C.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
#ifdef _WIN32
LANGUAGE 4, 2
#pragma code_page(936)
#endif //_WIN32
#include "res\BlackFinderTest.rc2" // non-Microsoft Visual C++ edited resources
#include "l.chs\afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

File diff suppressed because it is too large Load Diff

@ -0,0 +1,83 @@
// BlackFinderTestDlg.h : header file
//
#if !defined(AFX_BLACKFINDERTESTDLG_H__E441B700_6E63_415A_ADDE_5C875CF662AB__INCLUDED_)
#define AFX_BLACKFINDERTESTDLG_H__E441B700_6E63_415A_ADDE_5C875CF662AB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CBlackFinderTestDlg dialog
#define WM_HASH_LIST_LOADED WM_USER + 1001
class CBlackFinderTestDlg : public CDialog
{
// Construction
public:
CBlackFinderTestDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CBlackFinderTestDlg)
enum { IDD = IDD_BLACKFINDERTEST_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBlackFinderTestDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
private:
HANDLE hdledbf,hdlesql,hdlesql2;
CEdit * Pinfo;
// BOOL m_isLoad;
CString m_BasePath;
CString m_workPath;
CString m_TmpPath;
private:
void myInitDlg();
void AppendInfo(char * ptr);
void AppendInfo(CString & cstr);
CString GetDateTimeStr();
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CBlackFinderTestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnButtoncreate();
afx_msg void OnButtonTraversal();
afx_msg void OnButtonload();
afx_msg void OnButtonfind();
afx_msg void OnButtonversion();
afx_msg void OnButtonloadback();
afx_msg LRESULT OnMyListLoader(WPARAM w,LPARAM l);
afx_msg void OnBtnFind2();
afx_msg void OnButtonfindsql();
afx_msg void OnButtonversionsql();
afx_msg void OnButtoncreatesql();
afx_msg void OnButtonloadsql();
afx_msg void OnButtonsql();
afx_msg void OnBtnFindsql2();
afx_msg void OnButtonloadbacksql();
afx_msg void OnButtonfindsq3();
afx_msg void OnButtonsql2();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BLACKFINDERTESTDLG_H__E441B700_6E63_415A_ADDE_5C875CF662AB__INCLUDED_)

@ -0,0 +1,88 @@
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : BlackFinderTest
========================================================================
AppWizard has created this BlackFinderTest application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your BlackFinderTest application.
BlackFinderTest.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
BlackFinderTest.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CBlackFinderTestApp application class.
BlackFinderTest.cpp
This is the main application source file that contains the application
class CBlackFinderTestApp.
BlackFinderTest.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
BlackFinderTest.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
res\BlackFinderTest.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file BlackFinderTest.rc.
res\BlackFinderTest.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one dialog class:
BlackFinderTestDlg.h, BlackFinderTestDlg.cpp - the dialog
These files contain your CBlackFinderTestDlg class. This class defines
the behavior of your application's main dialog. The dialog's
template is in BlackFinderTest.rc, which can be edited in Microsoft
Visual C++.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named BlackFinderTest.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC42XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC42DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////

@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// BlackFinderTest.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

@ -0,0 +1,27 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__E45F4C25_7C5B_4C58_AD95_90776FF6452A__INCLUDED_)
#define AFX_STDAFX_H__E45F4C25_7C5B_4C58_AD95_90776FF6452A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__E45F4C25_7C5B_4C58_AD95_90776FF6452A__INCLUDED_)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1,13 @@
//
// BLACKFINDERTEST.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

@ -0,0 +1,58 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by BlackFinderTest.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_BLACKFINDERTEST_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_EDITINFO 1000
#define IDC_BUTTONCREATE 1001
#define IDC_BUTTONLOAD 1002
#define IDC_BUTTONLOADBACK 1003
#define IDC_BUTTONFIND 1004
#define IDC_EDITCARDID 1005
#define IDC_BUTTONVERSION 1006
#define IDC_BUTTONTIMELOAD 1007
#define IDC_EDIT_DBFNAME 1008
#define IDC_BUTTON_TRAVERSAL 1009
#define IDC_BUTTONCREATESQL 1009
#define IDC_EDITCOUNTS 1010
#define IDC_BTN_FIND2 1011
#define IDC_BUTTONFINDSQL 1012
#define IDC_EDITCARDID2 1013
#define IDC_EDITSQLID 1013
#define IDC_BTN_FINDSQL2 1014
#define IDC_BUTTONLOADBACKSQL 1015
#define IDC_BUTTONVERSIONSQL 1016
#define IDC_BUTTONLOADSQL 1017
#define IDC_EDIT_SQLNAME 1018
#define IDC_BUTTONSQL 1019
#define IDC_BUTTONFINDSQ3 1020
#define IDC_EDITSQLWHERE 1021
#define IDC_BUTTONSQL2 1022
#define IDC_BUTTONFINDSQL2 1023
#define IDC_EDITSQLID2 1024
#define IDC_BTN_FINDSQL3 1025
#define IDC_BUTTONLOADBACKSQL2 1026
#define IDC_BUTTONVERSIONSQL2 1027
#define IDC_BUTTONLOADSQL2 1028
#define IDC_EDIT_SQLNAME2 1029
#define IDC_BUTTONFINDSQ4 1030
#define IDC_EDITSQLWHERE2 1031
#define IDC_EDITPRIKEY 1032
#define IDC_EDITPRIKEY2 1033
#define IDC_EDITLOAD_BACK 1034
#define IDC_EDITLOAD_BACK2 1035
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1035
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Loading…
Cancel
Save