📄 global.cpp
字号:
#include "stdafx.h"
#include "define.h"
void GetString(char* tBuf, char* sBuf, int len, int& index)
{
memcpy(tBuf, sBuf+index, len);
index += len;
}
BYTE GetByte(char* sBuf, int& index)
{
int t_index = index;
index++;
return (BYTE)(*(sBuf+t_index));
}
int GetShort(char* sBuf, int& index)
{
index += 2;
return *(short*)(sBuf+index-2);
}
DWORD GetDWORD(char* sBuf, int& index)
{
index += 4;
return *(DWORD*)(sBuf+index-4);
}
float Getfloat(char* sBuf, int& index)
{
index += 4;
return *(float*)(sBuf+index-4);
}
void SetString(char* tBuf, char* sBuf, int len, int& index)
{
memcpy(tBuf+index, sBuf, len);
index += len;
}
void SetByte(char* tBuf, BYTE sByte, int& index)
{
*(tBuf+index) = (char)sByte;
index++;
}
void SetShort(char* tBuf, int sShort, int& index)
{
short temp = (short)sShort;
CopyMemory( tBuf+index, &temp, 2);
index += 2;
}
void SetDWORD(char* tBuf, DWORD sDWORD, int& index)
{
CopyMemory( tBuf+index, &sDWORD, 4);
index += 4;
}
void Setfloat ( char* tBuf, float sFloat, int& index )
{
CopyMemory( tBuf+index, &sFloat, 4);
index += 4;
}
int ParseSpace( char* tBuf, char* sBuf)
{
int i = 0, index = 0;
BOOL flag = FALSE;
while(sBuf[index] == ' ' || sBuf[index] == '\t')index++;
while(sBuf[index] !=' ' && sBuf[index] !='\t' && sBuf[index] !=(BYTE) 0){
tBuf[i++] = sBuf[index++];
flag = TRUE;
}
tBuf[i] = 0;
while(sBuf[index] == ' ' || sBuf[index] == '\t')index++;
if(!flag) return 0;
return index;
}
void GetProgPath( char* path )
{
char Buf[256], Path[256];
char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
::GetModuleFileName(AfxGetApp()->m_hInstance, Buf, 256);
_splitpath(Buf,drive,dir,fname,ext);
strcpy(Path, drive);
strcat(Path, dir);
strcpy( path, Path );
}
void LogFileWrite( LPCSTR logstr )
{
char ProgPath[256], LogFileName[256];
memset( ProgPath, 0x00, 256 );
memset( LogFileName, 0x00, 256 );
CFile file;
int loglength;
GetProgPath(ProgPath);
loglength = strlen( logstr );
sprintf( LogFileName, "%s\\Aujard.log", ProgPath);
file.Open( LogFileName, CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite );
file.SeekToEnd();
file.Write(logstr, loglength);
file.Close();
}
void DisplayErrorMsg(SQLHANDLE hstmt)
{
SQLCHAR SqlState[6], Msg[1024];
SQLINTEGER NativeError;
SQLSMALLINT i, MsgLen;
SQLRETURN rc2;
char logstr[512];
memset( logstr, NULL, 512 );
i = 1;
while ((rc2 = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, SqlState, &NativeError, Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)
{
sprintf( logstr, "*** %s, %d, %s, %d ***\r\n", SqlState,NativeError,Msg,MsgLen );
LogFileWrite( logstr );
// TRACE("*** %s, %d, %s, %d ***\n", SqlState,NativeError,Msg,MsgLen);
i++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -