pubfunc.cpp

来自「本软件带有源码」· C++ 代码 · 共 60 行

CPP
60 行
字号
// pubfunc.cpp: implementation of the pubfunc class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "pubfunc.h"

CString GetSysDate()
{
	CString strTemp;
	CTime t = CTime::GetCurrentTime();
	strTemp.Format("%04d/%02d/%02d", t.GetYear(), t.GetMonth(), t.GetDay());

	return strTemp;
}

CString GetSysTime()
{
	CString strTime;
	CTime t = CTime::GetCurrentTime();
	strTime.Format("%02d:%02d:%02d", t.GetHour(), t.GetMinute(), t.GetSecond());

	return strTime;
}

CString GetPath()
{
	CString strPath;
	char exePath[MAX_PATH];
	GetModuleFileName(NULL,exePath,MAX_PATH);
	strPath=exePath;

	strPath.Replace("/","\\");
	int pos=strPath.ReverseFind('\\');
	if(pos>=0)
		strPath=strPath.Left(pos+1);

	return strPath;
}

BOOL SetAccessODBC(char *dstName)
{
	CString szDesc;
	char dbName[60];
	char tmpPath[MAX_PATH];

	sprintf(dbName,"%s.mdb",dstName);
	strcpy(tmpPath,GetPath());
	szDesc.Format("DSN=%s|DESCRIPTION=%s|DBQ=%s|FIL=MicrosoftAccess|DEFAULTDIR=%s|",
			dstName,dstName,dbName,tmpPath);

	for(int i=0;i<szDesc.GetLength();i++){
		if(szDesc.GetAt(i)=='|') szDesc.SetAt(i,'\0');
	}
	SQLConfigDataSource(NULL,ODBC_ADD_DSN,
		"Microsoft Access Driver (*.mdb)\0",
		(LPCSTR)szDesc);

	return TRUE;
}

⌨️ 快捷键说明

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