⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbrecord2.cpp

📁 红外线文件传输 这是我“任何地点办公”理念所想到的
💻 CPP
字号:
#include <windows.h>
#include <windowsx.h>
#include <aygshell.h>
#include "resource.h"
#include "DBRecord.h"
#include "ErrorReporting.h"

ErrorReport erDBRecordcpp;

#pragma warning(disable: 4800)  

bool db::mountVol(LPTSTR _dbPath){
	bool bResult=CeMountDBVol(&m_guid,_dbPath,OPEN_ALWAYS);
	bResult ? true:false;
	if(!bResult){     //bResult = false;
		MessageBox(NULL, L"mount error!", L"MOUNT RESULT:",MB_OK);		
		return false;
	}
	return true;
}

bool db::createDB(LPTSTR _dbPath,LPTSTR _dbName){
		CEDBASEINFO ced;
		ZeroMemory(&ced,sizeof(CEDBASEINFO));
		ced.dwSize = sizeof(CEDBASEINFO);
		ced.dwFlags=CEDB_VALIDNAME;
		wcscpy(ced.szDbaseName,_dbName);
		wcscpy(dbName,_dbName);
		m_oid=CeCreateDatabaseEx(&m_guid,&ced);

		if(m_oid==NULL){
			MessageBox(NULL, L"create error!", L"create RESULT",MB_OK);			
			return false;
		}
			handleDB=CeOpenDatabaseEx(&m_guid,&m_oid,_dbName,NULL,0,NULL); //
			if(handleDB==INVALID_HANDLE_VALUE){
			MessageBox(NULL, L"open error!", L"create RESULT",MB_OK);
			erDBRecordcpp.Report();
			return false;
			}

			prgPropVal=new CEPROPVAL[1024];
			ZeroMemory(prgPropVal,sizeof(CEPROPVAL[1024]));
			prgPropVal[0].propid=MAKELONG(CEVT_I2,1);
			prgPropVal[0].val.iVal =0;   //row number is 0,that is, to me, empty record;
			m_oidRecord=CeWriteRecordProps(handleDB,0,1,prgPropVal);

			if(m_oidRecord==0){
				MessageBox(NULL, L"create write fail!", L"RESULT",MB_OK);
				return false;
			}else{
				MessageBox(NULL, L"create write done!", L"RESULT",MB_OK);
			    return true;
			}
}



bool db::writeFilename(LPTSTR _fileName){
	int rowNum;
	rowNum = prgPropVal[0].val.iVal;
	rowNum++;
	prgPropVal[0].propid=MAKELONG(CEVT_I2,1);
	prgPropVal[0].val.iVal = rowNum;  
	prgPropVal[rowNum].propid=MAKELONG(CEVT_LPWSTR,1);
	prgPropVal[rowNum].val.lpwstr = _fileName;
	CEOID oidRecord;
	rowNum++;
	oidRecord = CeWriteRecordProps(handleDB,0,rowNum,prgPropVal);
	if(oidRecord==0){
		erDBRecordcpp.Report();
		return false;
	}else{
		MessageBox(NULL, L"write file done!", L"writeFilename RESULT",MB_OK);
		return true;
	}
}

bool db::writeFiletime(FILETIME _ft){
	int rowNum;
	rowNum = prgPropVal[0].val.iVal;
	rowNum++;
	prgPropVal[0].propid=MAKELONG(CEVT_I2,1);
	prgPropVal[0].val.iVal = rowNum;  
	prgPropVal[rowNum].propid=MAKELONG(CEVT_FILETIME,1);
	prgPropVal[rowNum].val.filetime = _ft;
	CEOID oidRecord;
	rowNum++;
	oidRecord = CeWriteRecordProps(handleDB,0,rowNum,prgPropVal);
	if(oidRecord==0){
		erDBRecordcpp.Report();
		return false;
	}else{
		MessageBox(NULL, L"write time done!", L"writeFiletime RESULT",MB_OK);
		return true;
	}
}

bool db::readDB(){
		BYTE *prgBuffer = NULL;
		DWORD dwBuffer = 0;
		WORD wPropID = 0;
		CEOID oid;

		oid=CeReadRecordPropsEx(handleDB,0,&wPropID,NULL,&prgBuffer,&dwBuffer,NULL);
		if(oid!=0){
			prgPropVal=(PCEPROPVAL)prgBuffer;
			return true;
		}else
			return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -