锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
DWORD GetTickCount(void);
/*
Header: Winbase.h, include Windows.h
Link Library: Kernel32.lib
DLL: Dernel32.dll
Details:
The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. To obtain the system timer resolution, use the GetSystemTimeAdjustment function.
Remarks:
The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days.
Example Code:
The following example demonstrates how to use a this function to wait for a time interval to pass. Due to the nature of unsigned arithmetic, this code works correctly if the return value wraps one time. If the difference between the two calls to GetTickCount is more than 49.7 days, the return value could wrap more than one time and this code will not work.
DWORD dwStart = GetTickCount();
if( GetTickCount() - dwStart >= TIMELIMIT )
Cancel();
*/
void Sleep(DWORD dwMilliseconds);
/*
Header: Winbase.h, include Windows.h
Library: Kernel32.lib
DLL: Kernel32.dll
Details:
This function suspends the execution of the current thread for a specified interval.
Parameters:
Specifies the time, in milliseconds, for which to suspend execution.
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If no other threads of equal priority are ready to run, the function returns immediately, and the thread continues execution.
A value of INFINITE causes an infinite delay.
Remarks:
You have to be careful when using Sleep and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. If you have a thread that uses Sleep with infinite delay, the system will deadlock. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than Sleep.
*/
DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
/*
Header: Winbase.h, include Windows.h
Library: Kernel32.lib
DLL: Kernel32.dll
Details:
The WaitForSingleObject function returns when the specified object is in the signaled state or the time-out interval elapses.
Parameters:
hHandle:
Handle to the object. If this handle is closed while the wait is still pending, the function's behavior is undefined.
dwMilliseconds:
Time-out interval, in milliseconds. The function returns if the interval elapses, even if the object's state is nonsignaled. If dwMilliseconds is zero, the function tests the object's state and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
Return Values:
If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values.
WAIT_ABANDONED錛氬綋hHandle涓簃utex鏃訛紝濡傛灉鎷ユ湁mutex鐨勭嚎紼嬪湪緇撴潫鏃舵病鏈夐噴鏀炬牳蹇?jī)瀵硅薄浼?xì)寮曞彂姝よ繑鍥炲箋?br>WAIT_OBJECT_0錛氭牳蹇?jī)瀵硅薄宸茶婵媧?br>WAIT_TIMEOUT錛氱瓑寰呰秴鏃?br>WAIT_FAILED錛氬嚭鐜伴敊璇紝鍙氳繃GetLastError寰楀埌閿欒浠g爜
Remarks:
The WaitForSingleObject function checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters the wait state. It uses no processor time while waiting for the object state to become signaled or the time-out interval to elapse.
The function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one.
*/
HRESULT GetProcessorInfo(WORD* pwProcessorArchitectureOut, WORD* pwProcessorLevelOut);
/*
DLL: Clcfgsrv.dll
Details:
The GetProcessorInfo method retrieves the processor information for the node.
Parameters:
pwProcessorArchitectureOut: Processor architecture information.
pwProcessorLevelOut: Processor level information.
*/
DWORD_PTR SetThreadAffinityMask(HANDLE hThread, DWORD_PTR dwThreadAffinityMask);
/*
Header: Winbase.h, include Windows.h
DLL: Kernel32.dll
Library: Kernel32.lib
Details:
The SetThreadAffinityMask function sets a processor affinity mask for the specified thread.
Return Values:
If the function succeeds, the return value is the thread's previous affinity mask. Windows Me/98/95: The return value is 1. To succeed, hThread must be valid and dwThreadAffinityMask must be 1.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks:
A thread affinity mask is a bit vector in which each bit represents the processors that a thread is allowed to run on.
A thread affinity mask must be a proper subset of the process affinity mask for the containing process of a thread. A thread is only allowed to run on the processors its process is allowed to run on.
*/
DWORD timeGetTime(VOID);
/*
Header: Mmsystem.h, include Windows.h
Library: Winmm.lib
Details:
The timeGetTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started.
Remarks:
The only difference between this function and the timeGetSystemTime function is that timeGetSystemTime uses the MMTIME structure to return the system time. The timeGetTime function has less overhead than timeGetSystemTime.
Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days. This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.
*/
MMRESULT timeGetSystemTime(LPMMTIME pmmt, UINT cbmmt);
/*
Header: Mmsystem.h, include Windows.h
Library: Winmm.lib
Details:
The timeGetSystemTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started. This function works very much like the timeGetTime function. See timeGetTime for details of these functions' operation.
Parameters:
pmmt: Pointer to an MMTIME structure.
cbmmt: Size, in bytes, of the MMTIME structure.
Return Values:
Returns TIMERR_NOERROR. The system time is returned in the ms member of the MMTIME structure.
*/
鍦ㄤ嬌鐢╓indows.h涓畾涔夛細(xì)
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int UINT;
POSITION pos = pList->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = pList->GetNextSelectedItem(pos);
TRACE1("Item %d was selected!\n", nItem);
// you could do your own processing on nItem here
}
}
鏉℃鍗侊細(xì)鍒犻櫎鏉℃涔?jié)涓変腑鐨勮
榪欎釜鐩稿鍓嶉潰涔?jié)涓潯娆炬槸姣旇緝楹荤儲(chǔ)鐨勫Q屽洜涓哄鏋滀綘瑕佸垹闄ゅ琛岀殑璇濓紝寰寰瑕佸嚭閿欍傛瘮濡傦紝鎴戠幇鍦ㄨ鍒犻櫎絎?琛屽拰絎?琛岋紙鍒楄〃鐨勮搴忓垪鏄粠0寮濮嬬殑錛?br>閭d箞濂藉晩銆傛垜鏉ュ垹浜?br>
m_listctrl.DeleteItem(0)
m_listctrl.DeleteItem(1)
鎭枩浣狅紝閿欎簡(jiǎn)錛屾垜濂藉紑蹇?jī)鍟娿錛氾級(jí)
鍥犱負(fù)浣犲垹闄ょ0琛屼互鍚庯紝涓嬮潰鐨勮浼?xì)寰涓婄Щ錛岄偅涔堝師鏉ョ殑絎?琛屽氨鍙樻垚浜?jiǎn)绗?琛岋紝閭d箞浣犲啀 m_listctrl.DeleteItem(1)錛岄偅涔堝垹闄ょ殑鏄師鏉ョ殑絎紥琛岋紝鐪熼夯鐑?chǔ)锛?br>鎵浠ワ紝鍙湁浠庝笅寰涓婂垹錛屾墠鏄畨鍏ㄧ殑錛屽厛鍒犵殑錛屼笉浼?xì)濯?jiǎng)鍝嶅悗闈㈢殑鎿嶄綔錛?br>
m_listctrl.DeleteItem(1)
m_listctrl.DeleteItem(0)
浣嗘湁鏃跺欙紝鎴戜滑涔熶笉鐭ラ亾瑕佸垹闄ゅ摢浜涜錛屽彧鐭ラ亾瑕佸垹闄ら変腑鐨勯偅浜涜錛屽儚鏉℃涔?jié)涓殑閭d?br>濡傛灉鎴戜滑榪樻槸鐢?br>
POSITION pos = m_listctrl.GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE0("No items were selected!\n");
else
{
while (pos)
{
int nItem = m_listctrl.GetNextSelectedItem(pos);
m_listctrl.DeleteItem(nItem );
}
}
浣犲氨絳夌潃鏀跺案鍚?br>榪欐椂鍊欐垜浠氨瑕丅4寰蔣浜?jiǎn)锛屼给櫃揪c蟲湪鏈塆etLastselectedItemPosition 鍜孏etPrevSelectedItem錛屽鍐欎竴瀵規(guī)垚鍛樺嚱鏁頒細(xì)姝誨晩銆:(
娌″姙娉曪紝鍔炴硶鑷繁鎯籌紝榪欓噷鏈変釜絎ㄥ姙娉?br>
POSITION sSelPos = NULL;
while(sSelPos = m_listctrl.GetFirstSelectedItemPosition())
{
int nSelItem = -1;
nSelItem = m_listctrl.GetNextSelectedItem(sSelPos);
if(nSelItem >= 0 && nSelItem<m_listctrl.GetItemCount())
{
//濂戒簡(jiǎn)錛岃繖涓猲SelItem 灝辨槸鎴戜滑瑕佺殑DD
}
}
GetNextSelectedItem榪欎釜鍑芥暟錛岀湅msdn鐨勭敤娉曪紝鍏跺疄鏄繑鍥炵涓涓殑index錛岀劧鍚庤蛋鍒頒笅涓涓変腑鐨勮鍘伙紝鎵浠ヨ繖涔堝仛涔熸槸瀹夊叏鐨勶紝鍦ㄥ疄闄呬腑錛屼亢涔熸槸榪欎箞鍋氱殑錛屾祴璇曚篃閫氳繃錛屾病闂鐨?br>褰撶劧錛岃繕鏈変釜鍔炴硶錛屽厛閫氳繃GetFirstSelectedItemPosition鍜孏etNextSelectedItem鏉ヨ幏鍙栨墍鏈夌殑閫変腑琛岀殑index錛岀劧鍚庢妸榪欎簺index鏀懼埌涓涓暟緇勯噷錛岀劧鍚庡啀浠庝笅寰涓婂垹
鍞夌湡楹葷儲(chǔ)鍟婏紝榪樿涓嶅畾鏁扮粍錛屼笉璇寸敤new鍦ㄥ爢涓婂紑鍚э紝閭d箞涓涓獀ector鎬繪槸瑕佺殑鍚э紝楹葷儲(chǔ)鍟婏紝鎵浠ユ垜鏆傛椂鏄敤涓婅堪鐨勫姙娉曟潵鍒犻櫎錛屼篃渚涘ぇ瀹跺弬鑰冿紝甯屾湜鑳芥壘鍒版洿濂界殑鍔炴硶銆?br>
濂戒簡(jiǎn)錛屼粖澶╁氨鏆傛椂鍏堟暣鐞嗕笂榪板崄鐐廣俵istctrl鍏朵粬楂樼駭鐨勭敤娉曪紝緗戜笂璧勬枡涔熷緢澶氾紝鎴戜篃鏆傛椂涓嶆葷粨錛屼互鍚庢湁鏈轟細(xì)鍐嶈鍚с?br>
BOOL CDatabase::Open(
LPCTSTR lpszDSN,
BOOL bExclusive = FALSE,
BOOL bReadonly = FALSE,
LPCTSTR lpszConnect = _T("ODBC;"),
BOOL bUseCursorLib = TRUE );鍙傛暟璇存槑濡備笅錛?br>(1)lpszDSN錛氳榪炴帴鐨勬暟鎹簮鐨勫悕瀛楋紝濡傛灉lpszDSN = NULL涓攍pszConnect涓篃娌℃湁鎸囨槑鏁版嵁婧愬悕錛屽垯璇ヨ皟鐢ㄤ細(xì)鑷姩鍑虹幇涓涓璇濇鍒楀嚭鎵鏈夊彲鐢ㄧ殑鏁版嵁婧?鍚?錛岃鐢ㄦ埛閫夋嫨銆?br>(2)bExclusive錛氬彧鏀寔“鍋?#8221;(False)鍊鹼紝琛ㄧず涓哄叡浜?share)鏂瑰紡榪炴帴銆傚洜姝わ紝搴旂敤紼嬪簭鍦ㄨ繍琛屽墠錛屼竴瀹氳瑁呭叆share.exe鎴栧湪Windows鐨剆ystem.ini涓鍏share.386銆?浠涔堟剰鎬濅笉澶噦......)
(3)ReadOnly錛氭寚鏄庢暟鎹簮鎿嶄綔鏂瑰紡鏄?#8220;鍙”榪樻槸鍙互淇敼銆?br>(4)lpszConnect:錛氭寚鏄庤繛鎺ュ瓧絎︿覆錛屽寘鎷暟鎹簮鍚嶃佺敤鎴鋒爣璇嗙爜銆佸彛浠ょ瓑淇℃伅銆傝瀛楃涓插繀欏諱互“ODBC;”寮澶達(dá)紝琛ㄧず璇ヨ繛鎺ユ槸涓庝竴涓狾DBC鏁版嵁婧愮殑榪炴帴(鑰冭檻浠ュ悗鐗堟湰鏀寔闈濷DBC鏁版嵁婧?銆?br>
1.鏍規(guī)嵁Access鏂囦歡鐨勮礬寰勮繘琛岃繛鎺?/strong>
CString strConnect;
strConnect = _T("ODBC;DRIVER={MICROSOFT ACCESS DRIVER(*.mdb)};UID=;PWD=;DBQ=D:\\MusicSearch.mdb");
CDatabase db;
if(!db.Open(NULL, FALSE, FALSE, strConnect))

{
return TRUE;
}
CString strSQL;
strSQL = _T("select TOP 100 * from Music");
CRecordset rs(&db);
rs.Open(CRecordset::forwardOnly, strSQL);
CString strValue;
int i = 0;
while(!rs.IsEOF())

{
//娣誨姞鍔熻兘
rs.MoveNext();
i++;
} 
rs.Close();
db.Close();
2.閰嶇疆ODBC鏁版嵁婧愬悗榪炴帴
CDatabase db;
if(!db.Open(_T("MusicSearch")))

{
return TRUE;
}
CString strSQL;
strSQL = _T("select TOP 100 * from Music");
CRecordset rs(&db);
rs.Open(CRecordset::forwardOnly, strSQL);
//浠ヤ笅娣誨姞鍔熻兘
2. 瑕佽CSortList鑷鎺掑簭錛屽綋鐒跺緱璁〤SortList鑷繁澶勭悊LVN_COLUMNCLICK娑堟伅
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnLvnColumnclick)
OnLvnColumnclick鐨勪綔鐢ㄥ氨鏄緗帓搴忓垪錛屾帓搴忔柟寮忥紝鏈鍚庤皟鐢⊿ortItems()銆?/p>
3. 鎺掑簭鐨勫叿浣撳疄鐜幫紝涔熷氨鏄疌ALLBACK ListCompare(...)鐨勫疄鐜幫細(xì)
鍩烘湰瑕佹眰: 璁〤SortList鏍規(guī)嵁Item榪涜鎺掑簭錛岃屼笌鏁版嵁婧愭棤鍏熾?褰撶劧榪欐牱涔熸湁涓嶈凍涔嬪錛屽氨鏄帓搴忓彧鑳芥寜鏂囨湰鎺掑簭浜?jiǎn)銆傚鏋滀綘闇瑕佹寜鏁板瓧鎺掑簭鐨勮瘽錛岄偅灝卞彧鏈夌壒孌婂鐞嗕簡(jiǎn)銆?
榪欓噷娑夊強(qiáng)鍒扮殑鏈涓昏鐨勫嚱鏁版槸錛?br> (1)ListCompare - 瀹炵幇鎺掑簭鐨勫洖璋冨嚱鏁?br> int CALLBACK CSortList::ListCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)錛?br> (2)CListCtrl::FindItem - 鏌ユ壘鐩稿簲鐨処tem, 鏌ユ壘鏂瑰紡鍙寚瀹?br> int FindItem( LVFINDINFO* pFindInfo, int nStart = -1 ) const;
FindItem鐨勫叿浣撶粏鑺傝鍙傝僊SDN.
鍩烘湰鎬濊礬錛?br> (1)ListCompare鐨勫師鍨嬶細(xì)浼犲叆鐨勫弬鏁發(fā)Param1,lParam2鏄浉搴斾袱琛岀殑ItemData錛?br> (2)FindItem鏍規(guī)嵁lParam1,lParam2寰楀埌鐩稿簲鐨処tem錛?br> FindItem鏈夊縐嶆煡鎵炬柟寮?鏌ユ壘鏂瑰紡閫氳繃LVFINDINFO->flags榪涜璁劇疆)錛岃繖閲屽彧鏄牴鎹甀temData榪涜鏌ユ壘銆?br> (3)鍐嶇敤GetItemText寰楀埌鎺掑簭鍒楃殑ItemText錛?br> (4)鏈鍚庡氨鏄瘮杈僆temText浜?jiǎn)銆?br>
涓嬮潰鏄簮浠g爜錛?br>鍙湁涓や釜鏂囦歡錛欳SortListCtrl.H, CSortListCtrl.cpp
鐩存帴鎶婅繖涓や釜鏂囦歡鏀懼埌欏圭洰閲屽氨鍙互浜?jiǎn)銆?br>/Files/amazon/CSortListCtrl.rar
鍦ㄥ璇濇紼嬪簭C***Dlg涓紝鍙坊鍔犲涓嬪垵濮嬪寲淇℃伅錛岃緗帶浠剁殑椋庢牸鍜屾墿灞曢鏍箋傛敞鎰忚鏍規(guī)嵁HDITEM綾誨瀷鍙橀噺鍜孋HeaderCtrl::SetItem鍑芥暟璁劇疆鍒楃殑綾誨瀷灞炴с?br>
CSortListCtrl m_test;
//鍒濆鍖栨帶浠?/span>
DWORD dwStyle = ::GetWindowLong(m_test.m_hWnd, GWL_STYLE);
dwStyle &= ~(LVS_TYPEMASK);
dwStyle &= ~(LVS_EDITLABELS);
//璁劇疆鏂伴鏍?/span>
SetWindowLongW(m_test.m_hWnd, GWL_STYLE, dwStyle|LVS_REPORT|LVS_NOLABELWRAP|LVS_SHOWSELALWAYS);
//璁劇疆鎵╁睍椋庢牸
DWORD styles = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_CHECKBOXES;
ListView_SetExtendedListViewStyleEx(m_test.m_hWnd, styles, styles);
m_test.SetExtendedStyle(m_test.GetExtendedStyle() | LVS_EX_SUBITEMIMAGES);
HDITEM headerItem;
headerItem.mask = HDI_LPARAM;
CHeaderCtrl* pHeaderCtrl = m_test.GetHeaderCtrl( );
m_test.InsertColumn(0, _T("姝屾洸"), LVCFMT_LEFT, 150);





























.





























..
headerItem.lParam = CSortListCtrl::DATA_TYPE::STRING_TYPE;
pHeaderCtrl->SetItem(0, &headerItem);





























.





























..

CBitButtonNL m_btnSearch;
CString strFontName = _T("瀹嬩綋");
//set bitmap
m_btnSearch.SetBitmaps(
IDB_BITMAP_OTHER_NORMAL,
IDB_BITMAP_OTHER_DOWN,
IDB_BITMAP_OTHER_UP,
IDB_BITMAP_OTHER_NO); //鎸夐挳鐨勫洓縐嶄綅鍥?/span>
m_btnSearch.SetForceColor(RGB(0, 0, 0), RGB(0, 0, 0), RGB(0, 0, 0)); //鏂囧瓧棰滆壊
m_btnSearch.SetSound(MAKEINTRESOURCE(IDR_WAVEMOVE), ::GetModuleHandle(NULL)); //鑱氱劍澹伴煶
m_btnSearch.SetSound(MAKEINTRESOURCE(IDR_WAVECLICK), ::GetModuleHandle(NULL), TRUE); //鎸変笅澹伴煶
m_btnSearch.SizeToContent(); //鎸夐挳鑷姩閫傚簲絎竴涓浘鐗囧ぇ灝?/span>
m_btnSearch.SetWindowText(TEXT("鎼滅儲(chǔ)")); //鏀瑰彉鎸夐挳鏄劇ず鏂囧瓧
m_btnSearch.SetBtnCursor(IDC_CURSOR_HAND, FALSE); //鎸夐挳榧犳爣綾誨瀷
m_btnSearch.SetTextAlign(NL_ALIGN_CENTER, FALSE); //璁劇疆鏂囧瓧鎺掑垪鏂瑰紡
//set font
m_btnSearch
.SetDrawText(TRUE, FALSE) //鏄惁鏄劇ず鎸夐挳鏂囧瓧
.SetFont3D(FALSE, 3, 2, FALSE) //鏄劇ず鏂囧瓧3d鏁堟灉
.SetText3DBKColor(RGB(95, 95, 95)) //3d闃村獎(jiǎng)棰滆壊
.SetFontBold(TRUE, FALSE) //綺椾綋
.SetFontSize(10, FALSE) //瀛椾綋澶у皬
.SetFontName(strFontName) //瀛椾綋鍚嶇О
;涓鑸潵璇達(dá)紝瀹炵幇鏁版嵁搴撳埌ODBC椹卞姩紼嬪簭綆$悊鍣ㄧ殑娉ㄥ唽鏈変互涓嬩袱縐嶆柟娉曪細(xì)涓鏄紪紼嬫椂鎵嬪伐閰嶇疆ODBC鏁版嵁婧愶紝鍙戝竷鏃朵嬌鐢↖nstallShield絳夊畨瑁呭埗浣滆蔣浠惰嚜鍔ㄩ厤緗甇DBC鏁版嵁婧愶紱浜屾槸鑰冭檻鐢ㄧ▼搴忔浛鐢ㄦ埛瀹屾垚榪欎簺閰嶇疆宸ヤ綔錛屽疄鐜扮殑鏂規(guī)硶鏈夊嚑縐嶏紝涓縐嶅姙娉曟槸鐢ㄧ▼搴忎慨鏀筗indows娉ㄥ唽琛紝紼嬪簭鍛樺彲浠ョ敤Windows API鍑芥暟澧炴敼HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI涓殑閿鹼紝榪欑鏂規(guī)硶姣旇緝鐑?chǔ)鐞愬Q屽彟涓縐嶆槸鍦ㄧ▼搴忎腑浣跨敤ODBC API鐨勬柟娉曪紝紼嬪簭鍛樺彲浠ュ湪浠諱綍鏃跺欓兘鍙互鐢╒isual C++緙栧啓鐨勭▼搴忚皟鐢ㄨ繖浜汚PI鍑芥暟鏉ヨ緗甇DBC鏁版嵁婧愩?br>
鍒涘緩ODBC鏁版嵁婧愬彲浠ヨ皟鐢╓indows緋葷粺瀛愮洰褰曚笅鐨勫姩鎬侀摼鎺ュ簱ODBCCP32.DLL涓殑鍑芥暟SQLConfigDataSource()錛岃鍑芥暟鍙互鍔ㄦ佸湴澧炲姞銆佷慨鏀瑰拰鍒犻櫎鏁版嵁婧愩?br>
SQLConfigDataSource()鐨勫師鍨嬪涓?
BOOL SQLConfigDataSource(HWND hwndParent, UINT fRequest, LPCSTR IpszDriver, LPCSTR IpszAttributes);
鍏朵腑鍥涗釜鍙傛暟鐨勭敤娉曞涓?
鈼忓弬鏁癶wndPwent鏄埗綰х獥鍙e彞鏌勩傚鏋滃彞鏌勪負(fù)NULL錛屽皢涓嶄細(xì)鏄劇ず涓浜涙湁鍏崇殑瀵硅瘽妗嗐傚鏋滃弬鏁?IpszAttributes鎻愪緵鐨勪俊鎭笉澶熷畬鍠勶紝鍦ㄥ垱寤鴻繃紼嬩腑灝變細(xì)鍑虹幇瀵硅瘽妗嗚姹傜敤鎴鋒彁渚涚浉搴斾俊鎭?br>鈼忓弬鏁癴Request鍙互璁劇疆涓轟笅闈㈢殑鏁板間箣涓:
ODBC_ADD_DSN: 澧炲姞錛夸釜鏂版暟鎹簮
ODBC_CONHG_DSN: 閰嶇疆錛堜慨鏀?涓涓凡緇忓瓨鍦ㄧ殑鏁版嵁婧?br>ODBC_REMOVE_DSN: 鍒犻櫎涓涓凡緇忓瓨鍦ㄧ殑鏁版嵁婧?br>ODBC_ADD_SYS_DSN: 澧炲姞涓涓柊鐨勭郴緇熸暟鎹簮
ODBC_CONFIG_SYS_DSN: 鏇存敼涓涓凡緇忓瓨鍦ㄧ殑緋葷粺鏁版嵁婧?br>ODBC_REMOVE_SYS_DSN: 鍒犻櫎涓涓凡緇忓瓨鍦ㄧ殑緋葷粺鏁版嵁婧?br>鈼忓弬鏁發(fā)pszDriver鏄暟鎹簱寮曟搸鍚嶇О錛屽彲浠ュ弬瑙丱DBC綆$悊鍣ㄤ腑瀵筄DBC椹卞姩紼嬪簭鐨勬弿榪般傛瘮濡傝鍔犺澆鐨勬槸Excel鏁版嵁搴擄紝閭d箞鏁版嵁搴撳紩鎿庡悕縐板氨涓篗icrosoft Excel Driver(*.xls)
鈼忓弬鏁發(fā)pszAttributes涓轟竴榪炰覆鐨?KeyName=value"瀛楃涓詫紝姣忎袱涓狵eyName鍊間箣闂寸敤\0""瀛楃闅斿紑(鎴栬匼0闅斿紑鍗沖彲)銆侹eyName涓昏鏄柊鏁版嵁婧愮己鐪佺殑椹卞姩紼嬪簭娉ㄥ唽璇存槑錛屽叾涓渶涓昏鐨勫叧閿瓧鏄?DSN"(鏂版暟鎹簮鐨勫悕縐?鍜?DBQ"(鏁版嵁婧愮殑鍦板潃)錛屽叾浣欏叧閿瓧鍒欐牴鎹笉鍚岀殑鏁版嵁婧愭湁涓嶅悓瑕佹眰銆傚叧浜巐pszAttributes鍙傛暟鐨勫叿浣撹緗紝璇︾粏鍙互鍙傝僕indows緋葷粺鐩綍涓嬪府鍔╂枃浠禣dbcjtn.hlp涓婚鐩綍鏍囩涓殑"ODBC API鍑芥暟鏀瑰彉|SQLConfigDatasource"鏉$洰銆?br>
SqlConfigDataSource鐨勫簲鐢ㄦ潯浠訛細(xì)
浣跨敤SqlConfigDataSource鍑芥暟涔嬪墠錛屽繀欏繪妸ODBCINST.H鏂囦歡鍖呭惈鍦ㄥ伐紼嬪ご鏂囦歡涓紝灝哋DBCCP32.LIB鍔犲叆宸ョ▼錛屽悓鏃朵繚璇丱DBCCP32.DLL榪愯鏃跺浜庣郴緇熷瓙鐩綍涓嬨?br>鑻ヤ嬌鐢╒C6.0錛屽湪瀹夎鐩綍涓殑Lib鏂囦歡澶逛笅瀵繪壘ODBCCP32.LIB騫舵坊鍔犲埌宸ョ▼涓紱鑻ヤ嬌鐢ㄧ殑鏄疺C2005錛岃矊浼煎畨瑁呯洰褰曠殑lib鏂囦歡澶逛笅娌℃湁璇ib鏂囦歡錛屽彧鑳戒嬌鐢╒C6.0涓嬬殑......
渚嬶細(xì)
SQLConfigDataSource(
NULL,
ODBC_ADD_SYS_DSN,
"Microsoft Access Driver (*.mdb)",
"DSN=TryDB\0"
"DBQ=D:\\TryDB.mdb\0"
);