一,Base64編解碼。參考文章:《使用混合腳本程式設計來實作的Base64編碼》,《使用混合腳本程式設計來實作的Base64解碼》
二, 需求如下:一張jpg圖檔,将其位元組數組按Base64編碼後傳遞給用戶端,用戶端将此Base64編碼的字元串解碼後,最後還原為jpg圖檔。第一步Base64解碼請參考(1)中提到的文章《使用混合腳本程式設計來實作的Base64解碼》,下面給出還原為jpeg圖檔的代碼片段:
複制代碼
Code
CString rawByteStr = imgData; //解碼後的圖檔位元組數組字元串
//高4位位元組映射表
map<TCHAR,int> mapTable1;
mapTable1['f'] = 240;
mapTable1['e'] = 224;
mapTable1['d'] = 208;
mapTable1['c'] = 192;
mapTable1['b'] = 176;
mapTable1['a'] = 160;
mapTable1['9'] = 144;
mapTable1['8'] = 128;
mapTable1['7'] = 112;
mapTable1['6'] = 96;
mapTable1['5'] = 80;
mapTable1['4'] = 64;
mapTable1['3'] = 48;
mapTable1['2'] = 32;
mapTable1['1'] = 16;
mapTable1['0'] = 0;
//低4位位元組映射表
map<TCHAR,int> mapTable2;
mapTable2['f'] = 15;
mapTable2['e'] = 14;
mapTable2['d'] = 13;
mapTable2['c'] = 12;
mapTable2['b'] = 11;
mapTable2['a'] = 10;
mapTable2['9'] = 9;
mapTable2['8'] = 8;
mapTable2['7'] = 7;
mapTable2['6'] = 6;
mapTable2['5'] = 5;
mapTable2['4'] = 4;
mapTable2['3'] = 3;
mapTable2['2'] = 2;
mapTable2['1'] = 1;
mapTable2['0'] = 0;
//從位元組數組字元串還原為位元組數組
int count = rawByteStr.GetLength()/2;//位元組數
BYTE* Buffer = new BYTE[count]; //目标位元組緩沖區
int i,j;
for (i=0,j=0;i<rawByteStr.GetLength();i+=2)
{//計算并填充每個位元組
int sum = mapTable1[rawByteStr[i]]+mapTable2[rawByteStr[i+1]];
Buffer[j++] = sum;
}
//将位元組數組寫入jpeg檔案
DWORD BytesWritten;
HANDLE hTempFile;
BOOL fSuccess;
CString tmpFile = _T("C:\\tmpImg.jpg");
hTempFile = CreateFile(tmpFile.GetBuffer(10), // file name
GENERIC_WRITE, // open r-w
0, // do not share
NULL, // default security
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_NORMAL,// normal file
NULL); // no template
fSuccess = WriteFile(hTempFile,
Buffer,
count,
&BytesWritten,
NULL);
CloseHandle(hTempFile);
delete [] Buffer;
複制代碼
三,CodeProject上一個不錯的顯示圖檔的控件。文章連結:《WndImage Control》
四,二代身份證機具讀寫操作。參考文章:《不同機具的通用的第二代居民身份證讀寫》
五,在MFC中使用GDI+
1,在頭檔案中将GDI+的頭檔案包含進來
#include <GdiPlus.h>
using namespace Gdiplus;
2,聲明如下變量:
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
3,初始化和析構
BOOL CEhcicsApp::InitInstance()
{
……
// Initialize GDI+
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
return FALSE;
int CMyApp::ExitInstance()
// Release Gdi+ lib
GdiplusShutdown(gdiplusToken);
return CWinApp::ExitInstance();
六,使用FTP上傳/下載下傳檔案
1,在頭檔案中将要使用的網絡頭檔案包含進來
#include "afxinet.h"
CFtpConnection *m_pFtpConnection;
CInternetSession m_Session;
3,在OnInitDialog 或者InitInstance中加入:
m_pFtpConnection = NULL;
try
// Here usr is the username, pwd is the password
// and ftpsite.com is the name of the ftp site which
// you want to connect to.
m_pFtpConnection = m_Session.GetFtpConnection("ftpSite.com","usr","pwd",INTERNET_INVALID_PORT_NUMBER);
catch(CInternetException *pEx)
pEx->ReportError(MB_ICONEXCLAMATION);
m_pFtpConnection = NULL;
pEx->Delete();
4,要上傳檔案,加入如下代碼:
CFileFind Finder;
CString strFileName;
// Here c:\\Myfile.bmp is the name of the file that you want
// to upload. It neednt necessarily be a bitmap file. You
// can upload any file that you want to.
// The CString strFileName is used so that the same name
// is uploaded to the ftp server.
// After uploading, the file in the ftp server will have
// the same name as your local file.
// You can also rename it to anything
if(Finder.FindFile("C:\\Myfile.bmp")==TRUE)
Finder.FindNextFile();
strFileName = Finder.GetFileName();
Finder.Close();
BOOL bUploaded = m_pFtpConnection->PutFile("C:\\Myfile.bmp",strFileName,FTP_TRANSFER_TYPE_BINARY,1);
AfxMessageBox("Uploaded Successfully");
5,要下載下傳檔案,加入如下代碼:
m_pFtpConnection->GetFile("File.ext","C:\\File.ext",TRUE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,1);
6,關閉連接配接
m_Session.Close();
m_pFtpConnection->Close();
if(m_pFtpConnection!=NULL)
delete m_pFtpConnection;
七,Oracle解除安裝。
1)開始->設定->控制台->管理工具->服務停止所有Oracle服務;
2)開始->程式->Oracle – OraDb10g_home1>Oracle Installation Products-> Universal Installer 卸裝所有Oracle産品
3)在系統資料庫中删除HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
4)在系統資料庫中,選擇HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services,删除所有Oracle入口;
5)在系統資料庫中,選擇
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application,删除所有Oracle入口;
6)删除c:\Program Files\Oracle目錄;
7)重新啟動計算機,重新開機後才能完全删除Oracle所在目錄 ;
8)删除與Oracle有關的檔案,選擇Oracle所在的預設目錄C:\Oracle,删除這個入口目錄及所有子目錄,并從Windows XP目錄(一般為d:\WINDOWS)下删除以下檔案ORACLE.INI、oradim73.INI、oradim80.INI、 oraodbc.ini等等;
八,IBM Lotus文檔型資料庫導出到關系型資料庫。
解決方案:利用IBM提供的NotesSQL驅動程式,在java代碼中利用JDBC-ODBC橋去連接配接Lotus資料庫,進而讀取出Lotus資料庫中的資料。
值得注意的兩個地方:NotesSQL不支援Lotus中表單的中文域,并且表單名中不能包含’-‘這樣特殊的字元,再有一個就是表單如果改名稱,則在JDBC程式看來會被視為建立一個新表,而不是原表的簡單改名。是以在設計Lotus表單和視圖時,為了減輕後來維護者的痛苦考慮,萬望加倍小心。
此外,還有其他的導出工具和手段,但用JDBC連接配接Lotus應該是最簡單的一種了。
本文轉自Phinecos(洞庭散人)部落格園部落格,原文連結:http://www.cnblogs.com/phinecos/archive/2008/09/13/1290578.html,如需轉載請自行聯系原作者