EVC編程點滴(概述)-注冊表操作類
【生活經歷分享】華師國培 華師伴學 合同都是坑 消費者付款后無法退款
和華師國培簽合同需小心,合同中都是保護華師的條款,沒有保護消費者的條款。
收到錢,就算你因對培訓質量不滿意,也不能退款。因合同消費者維權肯定十分艱難。
華師伴學的授課方式是看錄制的視頻,不是真人現場教學。是否是您和孩子想要的學習方式?
各位打算報名的,交費要謹慎!
其他人在小紅書上發的,轉:
深圳市華師國培教育科技有限公司,黑心機構,大家擦亮眼睛,別被騙了,消費欺詐,虛假承諾,簽合同各種坑,收到錢了不履行承諾不退款,亂扣費,維權艱難! - 小紅書
我辭職前,在公司負責在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的內容:
1 #ifndef GSMPHONE_REG_H 2 #define GSMPHONE_REG_H 3 #include "wtypes.h" 4 class CRegOp 5 { 6 public: 7 BOOL DeleteKey(LPCTSTR szName); 8 BOOL DeleteValue(LPCTSTR szName); 9 BOOL SetMultiSZ(LPCTSTR szName, LPCTSTR lpszValue, DWORD dwLen); 10 BOOL SetBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen); 11 BOOL SetDW(LPCTSTR szName, DWORD dwValue); 12 BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue); 13 BOOL SetSZ(LPCTSTR szName, LPCTSTR szValue, DWORD dwLen); 14 DWORD GetValueDW(LPCTSTR szName, DWORD dwDefault=0); 15 LPCTSTR GetValueSZ(LPCTSTR szName); 16 LPBYTE GetValueBinary(LPCTSTR szName); 17 DWORD GetValueBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen); 18 BOOL GetValueSZ(LPCTSTR szName, LPTSTR szValue, DWORD dwLen); 19 BOOL EnumValue(LPTSTR pszName, DWORD dwLenName, LPTSTR pszValue, DWORD dwLenValue); 20 BOOL EnumKey(LPTSTR psz, DWORD dwLen); 21 BOOL IsOK(); 22 operator HKEY(); 23 void Reset(); 24 CRegOp(HKEY hkRoot, LPCTSTR pszKey); 25 BOOL Open(HKEY hkRoot, LPCTSTR pszKey, REGSAM sam=KEY_READ); 26 BOOL Create(HKEY hkRoot, LPCTSTR pszKey); 27 CRegOp(); 28 virtual ~CRegOp(); 29 private: 30 HKEY m_hKey; 31 int m_Index; 32 LPBYTE m_lpbValue; // last value read, if any 33 }; 34 #endif //#ifndef GSMPHONE_REG_H
(2)RegClass.cpp的內容:
1 #include "stdafx.h" 2 #include "RegClass.h" 3 //======================================================================= 4 //Macro define 5 #define MyFree(p) { / 6 if(p) LocalFree(p);/ 7 } 8 //======================================================================= 9 /**/////////////////////////////////////////////////////////////////////// 10 // Construction/Destruction 11 /**/////////////////////////////////////////////////////////////////////// 12 CRegOp::CRegOp() 13 { 14 m_hKey = NULL; 15 m_Index = 0; 16 m_lpbValue = NULL; 17 } 18 CRegOp::CRegOp(HKEY hkRoot, LPCTSTR pszKey) 19 { 20 m_hKey = NULL; 21 m_Index = 0; 22 m_lpbValue = NULL; 23 Open(hkRoot,pszKey); 24 } 25 CRegOp::~CRegOp() 26 { 27 if(m_hKey) 28 { 29 RegCloseKey(m_hKey); 30 } 31 MyFree(m_lpbValue); 32 } 33 //------------------------------------------------------------------- 34 //Description: 35 // Create the key 36 //------------------------------------------------------------------- 37 BOOL CRegOp::Create(HKEY hkRoot,LPCTSTR pszKey) 38 { 39 DWORD dwDisp; 40 return ERROR_SUCCESS == RegCreateKeyEx(hkRoot,pszKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&m_hKey,&dwDisp); 41 } 42 //------------------------------------------------------------------- 43 //Description: 44 // Open the key 45 //------------------------------------------------------------------- 46 BOOL CRegOp::Open(HKEY hkRoot,LPCTSTR pszKey,REGSAM sam) 47 { 48 return ERROR_SUCCESS == RegOpenKeyEx(hkRoot,pszKey,0,sam,&m_hKey); 49 } 50 //------------------------------------------------------------------- 51 //Description: 52 // Reset the value 53 //------------------------------------------------------------------- 54 void CRegOp::Reset() 55 { 56 if(m_hKey) 57 { 58 RegCloseKey(m_hKey); 59 } 60 MyFree(m_lpbValue); 61 m_hKey = NULL; 62 m_Index = 0; 63 m_lpbValue = NULL; 64 } 65 //------------------------------------------------------------------- 66 //Description: 67 // Operator overload 68 //------------------------------------------------------------------- 69 CRegOp::operator HKEY() 70 { 71 return m_hKey; 72 } 73 //------------------------------------------------------------------- 74 //Description: 75 // Test whether is the handle of the key OK for next operate 76 //------------------------------------------------------------------- 77 BOOL CRegOp::IsOK() 78 { 79 return m_hKey != NULL; 80 } 81 82 //------------------------------------------------------------------- 83 //Description: 84 // Enum the key 85 //------------------------------------------------------------------- 86 BOOL CRegOp::EnumKey(LPTSTR psz,DWORD dwLen) 87 { 88 if(!m_hKey) 89 { 90 return FALSE; 91 } 92 93 return ERROR_SUCCESS == RegEnumKeyEx(m_hKey,m_Index++,psz,&dwLen,NULL,NULL,NULL,NULL); 94 } 95 //------------------------------------------------------------------- 96 //Description: 97 // Enum registry Value 98 //------------------------------------------------------------------- 99 BOOL CRegOp::EnumValue(LPTSTR pszName,DWORD dwLenName,LPTSTR pszValue,DWORD dwLenValue) 100 { 101 DWORD dwType; 102 if(!m_hKey) 103 { 104 return FALSE; 105 } 106 107 dwLenValue *= sizeof(TCHAR); // convert length in chars to bytes 108 109 return ERROR_SUCCESS == RegEnumValue(m_hKey,m_Index++,pszName,&dwLenName,NULL,&dwType,(LPBYTE)pszValue,&dwLenValue); 110 } 111 //------------------------------------------------------------------- 112 //Description: 113 // Get the string value 114 //------------------------------------------------------------------- 115 BOOL CRegOp::GetValueSZ(LPCTSTR szName,LPTSTR szValue,DWORD dwLen) 116 { 117 if(!m_hKey) 118 { 119 return FALSE; 120 } 121 122 dwLen *= sizeof(TCHAR); // convert length in chars to bytes 123 124 return ERROR_SUCCESS == RegQueryValueEx(m_hKey,szName,NULL,NULL,(LPBYTE)szValue,&dwLen); 125 } 126 //------------------------------------------------------------------- 127 //Description: 128 // Get the binary value 129 //------------------------------------------------------------------- 130 DWORD CRegOp::GetValueBinary(LPCTSTR szName,LPBYTE lpbValue,DWORD dwLen) 131 { 132 if(!m_hKey) 133 { 134 return FALSE; 135 } 136 DWORD dwLenWant = dwLen; 137 if(ERROR_SUCCESS == RegQueryValueEx(m_hKey,szName,NULL,NULL,lpbValue,&dwLen)) 138 { 139 return dwLen; 140 } 141 else 142 { 143 return 0; 144 } 145 } 146 147 //------------------------------------------------------------------- 148 //Description: 149 // Get the binary value 150 //------------------------------------------------------------------- 151 LPBYTE CRegOp::GetValueBinary(LPCTSTR szName) 152 { 153 return (LPBYTE)GetValueSZ(szName); 154 } 155 156 //------------------------------------------------------------------- 157 //Description: 158 // Get the string value 159 //------------------------------------------------------------------- 160 LPCTSTR CRegOp::GetValueSZ(LPCTSTR szName) 161 { 162 return 0; 163 } 164 //------------------------------------------------------------------- 165 //Description: 166 // Get the DWORD value 167 // 168 //Parameters: 169 // szName:[in] The value of registry 170 // dwDefault:[in] The default value return when failed in getting the 171 //DWORD value. 172 //------------------------------------------------------------------- 173 DWORD CRegOp::GetValueDW(LPCTSTR szName,DWORD dwDefault) 174 { 175 if(!m_hKey) 176 { 177 return FALSE; 178 } 179 DWORD dwValue = dwDefault; 180 DWORD dwLen = sizeof(DWORD); 181 RegQueryValueEx(m_hKey,szName,NULL,NULL,(LPBYTE)&dwValue,&dwLen); 182 return dwValue; 183 } 184 //------------------------------------------------------------------- 185 //Description: 186 // Set the string value 187 //------------------------------------------------------------------- 188 BOOL CRegOp::SetSZ(LPCTSTR szName,LPCTSTR szValue,DWORD dwLen) 189 { 190 //Prefix 191 if(!m_hKey) 192 { 193 return FALSE; 194 } 195 196 return ERROR_SUCCESS == RegSetValueEx(m_hKey,szName,0,REG_SZ,(LPBYTE)szValue,sizeof(TCHAR)*dwLen); 197 } 198 199 //------------------------------------------------------------------- 200 //Description: 201 // Set the string value 202 //------------------------------------------------------------------- 203 BOOL CRegOp::SetSZ(LPCTSTR szName, LPCTSTR szValue) 204 { 205 return SetSZ(szName, szValue, 1+lstrlen(szValue)); 206 } 207 208 //------------------------------------------------------------------- 209 //Description: 210 // Get the DWORD value 211 //------------------------------------------------------------------- 212 BOOL CRegOp::SetDW(LPCTSTR szName, DWORD dwValue) 213 { 214 //Prefix 215 if(!m_hKey) 216 { 217 return FALSE; 218 } 219 220 return ERROR_SUCCESS==RegSetValueEx(m_hKey, szName, 0, REG_DWORD, (LPBYTE)&dwValue, sizeof(DWORD)); 221 } 222 223 //------------------------------------------------------------------- 224 //Description: 225 // Get the binary value 226 //------------------------------------------------------------------- 227 BOOL CRegOp::SetBinary(LPCTSTR szName, LPBYTE lpbValue, DWORD dwLen) 228 { 229 //Prefix 230 if(!m_hKey) 231 { 232 return FALSE; 233 } 234 return ERROR_SUCCESS == RegSetValueEx(m_hKey, szName, 0, REG_BINARY, lpbValue, dwLen); 235 } 236 237 //------------------------------------------------------------------- 238 //Description: 239 // Set the Multi value 240 //------------------------------------------------------------------- 241 BOOL CRegOp::SetMultiSZ(LPCTSTR szName, LPCTSTR lpszValue, DWORD dwLen) 242 { 243 return ERROR_SUCCESS == RegSetValueEx(m_hKey, szName, 0, REG_MULTI_SZ, (LPBYTE)lpszValue, sizeof(TCHAR)*dwLen); 244 } 245 246 //------------------------------------------------------------------- 247 //Description: 248 // Delete the value 249 //------------------------------------------------------------------- 250 BOOL CRegOp::DeleteValue(LPCTSTR szName) 251 { 252 //Prefix 253 if(!m_hKey) 254 { 255 return FALSE; 256 } 257 // 258 return ERROR_SUCCESS == RegDeleteValue(m_hKey, szName); 259 } 260 261 //------------------------------------------------------------------- 262 //Description: 263 // Delete Key 264 //------------------------------------------------------------------- 265 BOOL CRegOp::DeleteKey(LPCTSTR szName) 266 { 267 if(!m_hKey) 268 { 269 return FALSE; 270 } 271 272 return ERROR_SUCCESS == RegDeleteKey(m_hKey, szName); 273 }

浙公網安備 33010602011771號