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

📄 stdafx.cpp

📁 一个完整的数字硬盘录像机系统软件
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// stdafx.cpp : source file that includes just the standard includes
//	GtMpeg.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"
#include "lib\ViewCtl.h"
#include "lib\RecCtl.h"

BOOL	        g_bSlotOpened[_MAX_SLOT_NUMBER];
CDeviceObject*  g_pDevice[_MAX_SLOT_NUMBER];
//////////////////////////////////////////////
//
//////////////////////////////////////////////
CString GetAppPath( )
{
	CString  sPathName;
	sPathName=AfxGetApp()->GetProfileString("WorkDir","WorkDir");
    sPathName+="\\";
	return sPathName;
}
///////////////////////////////////
//
//////////////////////////////////
int  StringToInt(CString String)
{
 if(String.IsEmpty()) return 0;
 int ret=0;
 BOOL Flag=TRUE;
 CString TempString=String;
 TempString.TrimLeft();
 if(TempString.GetAt(0)=='-') 
 {
   Flag=FALSE;
   TempString=TempString.Right(TempString.GetLength()-1);
 }
 BYTE Bit=48;
 for(int i=0;i<TempString.GetLength();i++)
 {
   if(TempString.GetAt(i)>=48&&TempString.GetAt(i)<=57)
     Bit=TempString.GetAt(i);
   if(ret==0) ret=(int)Bit-48;
   else
   {
      ret*=10;
	  ret+=(int)Bit-48;
   }
 }
 if(Flag==FALSE) ret*=-1;
 return ret;
}
/////////////////////////////////////////////
//
/////////////////////////////////////////////
void GetDriveList(UINT nType,CStringArray &DriveList)
{
	TCHAR buff[256];
	GetLogicalDriveStrings(sizeof(buff)/sizeof(TCHAR),buff);
	CString Drive;
	int Pos=0;
	while(1)
	{
		Drive=&buff[Pos];
		if(Drive.IsEmpty())
			break;
		Pos+=Drive.GetLength()+1;
		Drive.MakeUpper();
		UINT nTmp=GetDriveType(Drive);
        if(nTmp==nType)
            DriveList.Add(Drive);
	}
}
///////////////////////////////////////
//
///////////////////////////////////////
DWORD GetDiskFreeSpace(CString sRoot)
{
    ULARGE_INTEGER dwFreeBytesAvailableToCaller,dwTotalNumberOfBytes,dwTotalNumberOfFreeBytes;
	char strRoot[MAX_PATH];
	strcpy(strRoot,sRoot);
    GetDiskFreeSpaceEx(strRoot,&dwFreeBytesAvailableToCaller,&dwTotalNumberOfBytes,&dwTotalNumberOfFreeBytes);
	ULONGLONG fFreeSpace=dwFreeBytesAvailableToCaller.QuadPart;///1024;
	return fFreeSpace/1024/1024;
}
///////////////////////////////////////
//
///////////////////////////////////////
DWORD GetDiskFreeSpaceScale(CString sRoot)
{
    ULARGE_INTEGER dwFreeBytesAvailableToCaller,dwTotalNumberOfBytes,dwTotalNumberOfFreeBytes;
	char strRoot[MAX_PATH];
	strcpy(strRoot,sRoot);
    GetDiskFreeSpaceEx(strRoot,&dwFreeBytesAvailableToCaller,&dwTotalNumberOfBytes,&dwTotalNumberOfFreeBytes);
	ULONGLONG  fFreeSpace=dwFreeBytesAvailableToCaller.QuadPart;///1024;
	ULONGLONG  fAllSpace=dwTotalNumberOfBytes.QuadPart;
	DWORD dwTmp=fFreeSpace*100/fAllSpace;
	return 100-dwTmp;
}
//////////////////////////////////
//
//////////////////////////////////
CString GetRootPath(CString sPath)
{
   CString sRoot=sPath.Left(3);
   return  sRoot;
}
/////////////////////////////////////////////////////////////////////////
//将数字字符串转换为实数
/////////////////////////////////////////////////////////////////////////
double  StringToFloat(CString String)
{
  char *FloatChar;
  int FloatLen=String.GetLength(),i;
  double ret;
  FloatChar=new (char [FloatLen+1]);
  for(i=0;i<=FloatLen;i++) FloatChar[i]=0;
  for(i=0;i<FloatLen;i++) FloatChar[i]=String.GetAt(i);
  ret=atof(FloatChar);
  delete FloatChar;
  return  ret;
}
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
CString GetWindowsDirectory()
{
	TCHAR WindowDir[MAX_PATH];
	for(int i=0;i<MAX_PATH;i++)
           WindowDir[i]=0;
	GetWindowsDirectory(WindowDir,MAX_PATH);
	return WindowDir;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CString  GetSystemDirectory()
{
	TCHAR WindowDir[MAX_PATH];
	for(int i=0;i<MAX_PATH;i++)
           WindowDir[i]=0;
   GetSystemDirectory(WindowDir,MAX_PATH);
   return WindowDir;
}
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
CString GetCurrentDirectory()
{
	TCHAR CurrentPath[MAX_PATH];
	for(int i=0;i<MAX_PATH;i++)
           CurrentPath[i]=0;
	::GetCurrentDirectory(MAX_PATH,CurrentPath);
	CString sCurrentPath=CurrentPath;
	return sCurrentPath;
}
/////////////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////////////
CString GetRegValueString(HKEY hKey,CString strKey,CString strChildKey,CString sDefault)
{
  HKEY hChildKey=0;
  if(RegOpenKey(hKey,(LPCTSTR)strKey,&hChildKey)!=ERROR_SUCCESS) 
	  return sDefault;
  CString strValue;
  DWORD dwType, dwCount;
  LONG lResult = RegQueryValueEx(hChildKey, (LPCTSTR)strChildKey, NULL, &dwType,
			NULL, &dwCount);
  if (lResult == ERROR_SUCCESS)
  {
	ASSERT(dwType == REG_SZ);
	lResult = RegQueryValueEx(hChildKey, (LPCTSTR)strChildKey, NULL, &dwType,
			(LPBYTE)strValue.GetBuffer(dwCount/sizeof(TCHAR)), &dwCount);
		strValue.ReleaseBuffer();
  }
  RegCloseKey(hChildKey);
  if (lResult == ERROR_SUCCESS)
  {
		ASSERT(dwType == REG_SZ);
		return strValue;
  }
  return sDefault;
}
////////////////////////////////////
//
///////////////////////////////////
int GetRegValueInt(HKEY hKey,CString strKey,CString strChildKey,int nDefault)
{
  HKEY hChildKey=0;
  if(RegOpenKey(hKey,(LPCTSTR)strKey,&hChildKey)!=ERROR_SUCCESS) 
	  return nDefault;
  DWORD dwValue;
  DWORD dwType;
  DWORD dwCount = sizeof(DWORD);
  LONG lResult = RegQueryValueEx(hChildKey, (LPCTSTR)strChildKey, NULL, &dwType,
			(LPBYTE)&dwValue, &dwCount);
  RegCloseKey(hChildKey);
  if (lResult == ERROR_SUCCESS)
  {
		ASSERT(dwType == REG_DWORD);
		ASSERT(dwCount == sizeof(dwValue));
		return (UINT)dwValue;
  }
  return nDefault;
}
///////////////////////////////////////
//
//////////////////////////////////////
void SetRegValueString(HKEY hKey,CString strKey,CString strChildKey,CString strChildKeyValue)
{
  HKEY hChildKey=0;
  DWORD dwDisposition;
  RegCreateKeyEx(hKey,(LPCTSTR)strKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_CREATE_SUB_KEY|KEY_ALL_ACCESS,
	  NULL,&hChildKey,
	  &dwDisposition);
  RegSetValueEx(hChildKey,(LPCTSTR)strChildKey,0,
	            REG_SZ,(const BYTE *)(LPCTSTR)strChildKeyValue,
				(DWORD)strChildKeyValue.GetLength());
  RegCloseKey(hChildKey);
}
///////////////////////////////////////
//
//////////////////////////////////////
void SetRegValueInt(HKEY hKey,CString strKey,CString strChildKey,int nValue)
{
  HKEY hChildKey=0;
  DWORD dwDisposition;
  RegCreateKeyEx(hKey,(LPCTSTR)strKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_CREATE_SUB_KEY|KEY_ALL_ACCESS,
	  NULL,&hChildKey,
	  &dwDisposition);
  RegSetValueEx(hChildKey,(LPCTSTR)strChildKey,0,
	            REG_DWORD,(LPBYTE)&nValue, sizeof(nValue));
  RegCloseKey(hChildKey);
}
///////////////////////////////////////////////////////////////////////////////////////////
//图形函数
///////////////////////////////////////////////////////////////////////////////////////////
void Line(int sx,int sy,int ex,int ey,int color,CDC *pDC)
{
   CPen pen(PS_SOLID,1,GetCurrentColor(color));
   CPen* pOldPen=pDC->SelectObject(&pen);
   pDC->SelectStockObject(NULL_BRUSH);
   pDC->MoveTo(sx,sy);
   pDC->LineTo(ex,ey);
   pDC->SelectObject(pOldPen);
}
////////////////////////////////////
//
///////////////////////////////////////
void LineWidth(int sx,int sy,int ex,int ey,int lineWidth,int Color,CDC* pDC)
{
   CPen pen(PS_SOLID,lineWidth,GetCurrentColor(Color));
   CPen* pOldPen=pDC->SelectObject(&pen);

⌨️ 快捷键说明

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