我辞职前,在公司负责在Windows CE系统上,通过串口控制GSM模块,实现一般手机的功能。即通话、SMS、通话记录、电话本(SIM和手机上);还有设置部分,如一般手机上的;然后就是多媒体部分,如Camera拍照、录音、图片浏览与一些基本操作;最后就是一些小的工具,如手机号码归属地查询、秒表、备忘录等。
还有就是Windows CE系统定制,如前述文章所描述的那样。
其实编程都是很细节的问题,一般都是发现再想办法解决。在解决过程中积累经验,现在辞职了,我就想将以前工作遇到的问题、和一些内容进行整理。对自己也是再学习的过程。这里主要整理EVC编程相关的部分,很多内容也是以前在网上查找到的(希望不会有侵权问题出现,如果出现请联系我,我将进行处理。多谢!)
今天先列个目录出来,后继再慢慢的完善啦!
1)注册表操作类
2)GIF动画显示类
3)TIMER的测试
4)键盘钩子
5)GSM模块的问题
6)图片游览:CxImage和VOImage
7)手机号码归属地查询
此功能用于来电时,直接显示号码所属地;同时提供一个小的工具,用户可以自己输入号码进行查询。
8)日历与时间控件
9)多语言的实现
10)界面实现的一些想法
11)输入法状态栏的处理
12)日历算法
13)拍照功能的实现
14)录音(WAV)格式
15)GSM AT命令
今天只能想起这么多了,以后想到再更新。
先说说注册表操作类,这个类在网上有很多实现的版本。我也在网上找到一个CE下注册表操作的源代码,实现风格与PC平台上的regedit的风格类似。大家可以去找来参考!
(1)RegClass.h的内容:
#ifndef GSMPHONE_REG_H
#define GSMPHONE_REG_H
#include "wtypes.h"
class CRegOp
{
public:
BOOL DeleteKey(LPCTSTR szName);
BOOL DeleteValue(LPCTSTR szName);
BOOL SetMultiSZ(LPCTSTR szName, LPCTSTR lpszValue, DWORD dwLen);
BOOL SetBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen);
BOOL SetDW(LPCTSTR szName, DWORD dwValue);
BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue);
BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue, DWORD dwLen);
DWORD GetValueDW(LPCTSTR szName, DWORD dwDefault=0);
LPCTSTR GetValueSZ(LPCTSTR szName);
LPBYTE GetValueBinary(LPCTSTR szName);
DWORD GetValueBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen);
BOOL GetValueSZ(LPCTSTR szName, LPTSTR szValue, DWORD dwLen);
BOOL EnumValue(LPTSTR pszName, DWORD dwLenName, LPTSTR pszValue, DWORD dwLenValue);
BOOL EnumKey(LPTSTR psz, DWORD dwLen);
BOOL IsOK();
operator HKEY();
void Reset();
CRegOp(HKEY hkRoot, LPCTSTR pszKey);
BOOL Open(HKEY hkRoot, LPCTSTR pszKey, REGSAM sam=KEY_READ);
BOOL Create(HKEY hkRoot, LPCTSTR pszKey);
CRegOp();
virtual ~CRegOp();
private:
HKEY m_hKey;
int m_Index;
LPBYTE m_lpbValue; // last value read, if any
};
#endif //#ifndef GSMPHONE_REG_H
(2)RegClass.cpp的内容:
#include "stdafx.h"
#include "RegClass.h"
//=======================================================================
//Macro define
#define MyFree(p) { /
if(p) LocalFree(p);/
}
//=======================================================================
/**///////////////////////////////////////////////////////////////////////
// Construction/Destruction
/**///////////////////////////////////////////////////////////////////////
CRegOp::CRegOp()
{
m_hKey = NULL;
m_Index = 0;
m_lpbValue = NULL;
}
CRegOp::CRegOp(HKEY hkRoot, LPCTSTR pszKey)
{
m_hKey = NULL;
m_Index = 0;
m_lpbValue = NULL;
Open(hkRoot,pszKey);
}
CRegOp::~CRegOp()
{
if(m_hKey)
{
RegCloseKey(m_hKey);
}
MyFree(m_lpbValue);
}
//-------------------------------------------------------------------
//Description:
// Create the key
//-------------------------------------------------------------------
BOOL CRegOp::Create(HKEY hkRoot,LPCTSTR pszKey)
{
DWORD dwDisp;
return ERROR_SUCCESS == RegCreateKeyEx(hkRoot,pszKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&m_hKey,&dwDisp);
}
//-------------------------------------------------------------------
//Description:
// Open the key
//-------------------------------------------------------------------
BOOL CRegOp::Open(HKEY hkRoot,LPCTSTR pszKey,REGSAM sam)
{
return ERROR_SUCCESS == RegOpenKeyEx(hkRoot,pszKey,0,sam,&m_hKey);
}
//-------------------------------------------------------------------
//Description:
// Reset the value
//-------------------------------------------------------------------
void CRegOp::Reset()
{
if(m_hKey)
{
RegCloseKey(m_hKey);
}
MyFree(m_lpbValue);
m_hKey = NULL;
m_Index = 0;
m_lpbValue = NULL;
}
//-------------------------------------------------------------------
//Description:
// Operator overload
//-------------------------------------------------------------------
CRegOp::operator HKEY()
{
return m_hKey;
}
//-------------------------------------------------------------------
//Description:
// Test whether is the handle of the key OK for next operate
//-------------------------------------------------------------------
BOOL CRegOp::IsOK()
{
return m_hKey != NULL;
}
//-------------------------------------------------------------------
//Description:
// Enum the key
//-------------------------------------------------------------------
BOOL CRegOp::EnumKey(LPTSTR psz,DWORD dwLen)
{
if(!m_hKey)
{
return FALSE;
}
return ERROR_SUCCESS == RegEnumKeyEx(m_hKey,m_Index++,psz,&dwLen,NULL,NULL,NULL,NULL);
}
//-------------------------------------------------------------------
//Description:
// Enum registry Value
//-------------------------------------------------------------------
BOOL CRegOp::EnumValue(LPTSTR pszName,DWORD dwLenName,LPTSTR pszValue,DWORD dwLenValue)
{
DWORD dwType;
if(!m_hKey)
{
return FALSE;
}
dwLenValue *= sizeof(TCHAR); // convert length in chars to bytes
return ERROR_SUCCESS == RegEnumValue(m_hKey,m_Index++,pszName,&dwLenName,NULL,&dwType,(LPBYTE)pszValue,&dwLenValue);
}
//-------------------------------------------------------------------
//Description:
// Get the string value
//-------------------------------------------------------------------
BOOL CRegOp::GetValueSZ(LPCTSTR szName,LPTSTR szValue,DWORD dwLen)
{
if(!m_hKey)
{
return FALSE;
}
dwLen *= sizeof(TCHAR); // convert length in chars to bytes
return ERROR_SUCCESS == RegQueryValueEx(m_hKey,szName,NULL,NULL,(LPBYTE)szValue,&dwLen);
}
//-------------------------------------------------------------------
//Description:
// Get the binary value
//-------------------------------------------------------------------
DWORD CRegOp::GetValueBinary(LPCTSTR szName,LPBYTE lpbValue,DWORD dwLen)
{
if(!m_hKey)
{
return FALSE;
}
DWORD dwLenWant = dwLen;
if(ERROR_SUCCESS == RegQueryValueEx(m_hKey,szName,NULL,NULL,lpbValue,&dwLen))
{
return dwLen;
}
else
{
return 0;
}
}
//-------------------------------------------------------------------
//Description:
// Get the binary value
//-------------------------------------------------------------------
LPBYTE CRegOp::GetValueBinary(LPCTSTR szName)
{
return (LPBYTE)GetValueSZ(szName);
}
//-------------------------------------------------------------------
//Description:
// Get the string value
//-------------------------------------------------------------------
LPCTSTR CRegOp::GetValueSZ(LPCTSTR szName)
{
return 0;
}
//-------------------------------------------------------------------
//Description:
// Get the DWORD value
//
//Parameters:
// szName:[in] The value of registry
// dwDefault:[in] The default value return when failed in getting the
//DWORD value.
//-------------------------------------------------------------------
DWORD CRegOp::GetValueDW(LPCTSTR szName,DWORD dwDefault)
{
if(!m_hKey)
{
return FALSE;
}
DWORD dwValue = dwDefault;
DWORD dwLen = sizeof(DWORD);
RegQueryValueEx(m_hKey,szName,NULL,NULL,(LPBYTE)&dwValue,&dwLen);
return dwValue;
}
//-------------------------------------------------------------------
//Description:
// Set the string value
//-------------------------------------------------------------------
BOOL CRegOp::SetSZ(LPCTSTR szName,LPCTSTR szValue,DWORD dwLen)
{
//Prefix
if(!m_hKey)
{
return FALSE;
}
return ERROR_SUCCESS == RegSetValueEx(m_hKey,szName,0,REG_SZ,(LPBYTE)szValue,sizeof(TCHAR)*dwLen);
}
//-------------------------------------------------------------------
//Description:
// Set the string value
//-------------------------------------------------------------------
BOOL CRegOp::SetSZ(LPCTSTR szName, LPCTSTR szValue)
{
return SetSZ(szName, szValue, 1+lstrlen(szValue));
}
//-------------------------------------------------------------------
//Description:
// Get the DWORD value
//-------------------------------------------------------------------
BOOL CRegOp::SetDW(LPCTSTR szName, DWORD dwValue)
{
//Prefix
if(!m_hKey)
{
return FALSE;
}
return ERROR_SUCCESS==RegSetValueEx(m_hKey, szName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD));
}
//-------------------------------------------------------------------
//Description:
// Get the binary value
//-------------------------------------------------------------------
BOOL CRegOp::SetBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen)
{
//Prefix
if(!m_hKey)
{
return FALSE;
}
return ERROR_SUCCESS == RegSetValueEx(m_hKey, szName, 0, REG_BINARY, lpbValue, dwLen);
}
//-------------------------------------------------------------------
//Description:
// Set the Multi value
//-------------------------------------------------------------------
BOOL CRegOp::SetMultiSZ(LPCTSTR szName, LPCTSTR lpszValue, DWORD dwLen)
{
return ERROR_SUCCESS == RegSetValueEx(m_hKey, szName, 0, REG_MULTI_SZ, (LPBYTE)lpszValue, sizeof(TCHAR)*dwLen);
}
//-------------------------------------------------------------------
//Description:
// Delete the value
//-------------------------------------------------------------------
BOOL CRegOp::DeleteValue(LPCTSTR szName)
{
//Prefix
if(!m_hKey)
{
return FALSE;
}
//
return ERROR_SUCCESS == RegDeleteValue(m_hKey, szName);
}
//-------------------------------------------------------------------
//Description:
// Delete Key
//-------------------------------------------------------------------
BOOL CRegOp::DeleteKey(LPCTSTR szName)
{
if(!m_hKey)
{
return FALSE;
}
return ERROR_SUCCESS == RegDeleteKey(m_hKey, szName);
}