锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产欧美 在线欧美,欧美一区二区三区在线,韩曰欧美视频免费观看http://m.shnenglu.com/huangyi5209/category/15847.htmlzh-cnSun, 29 May 2011 02:54:37 GMTSun, 29 May 2011 02:54:37 GMT60maximum contiguous subsequence sum algorithm 鏈澶у瓙搴忓垪綆楁硶http://m.shnenglu.com/huangyi5209/articles/144084.htmlhuangyi5209huangyi5209Tue, 12 Apr 2011 23:13:00 GMThttp://m.shnenglu.com/huangyi5209/articles/144084.htmlhttp://m.shnenglu.com/huangyi5209/comments/144084.htmlhttp://m.shnenglu.com/huangyi5209/articles/144084.html#Feedback0http://m.shnenglu.com/huangyi5209/comments/commentRss/144084.htmlhttp://m.shnenglu.com/huangyi5209/services/trackbacks/144084.html闃呰鍏ㄦ枃

]]>
InterlockedExchange 綰跨▼鍚屾http://m.shnenglu.com/huangyi5209/articles/142860.htmlhuangyi5209huangyi5209Mon, 28 Mar 2011 08:09:00 GMThttp://m.shnenglu.com/huangyi5209/articles/142860.htmlhttp://m.shnenglu.com/huangyi5209/comments/142860.htmlhttp://m.shnenglu.com/huangyi5209/articles/142860.html#Feedback0http://m.shnenglu.com/huangyi5209/comments/commentRss/142860.htmlhttp://m.shnenglu.com/huangyi5209/services/trackbacks/142860.html 

    #include <iostream>
#include 
<Windows.h>

using namespace std;

volatile LONG lfsSpinLock = 0;
int num = 0;
// lfsSpinLock is a 'long' and when it is '1' it is locked, and '0' is unlocked
#define  ENTER_LFS_LOCK_   while( InterlockedExchange( &lfsSpinLock, 1 ) == 1 ){ Sleep( 10 ); }
#define  EXIT_LFS_LOCK_    InterlockedExchange( &lfsSpinLock, 0 );


void Func1() 


    
//Wait to access the resource.  絳夊緟璧勬簮 

    ENTER_LFS_LOCK_;

    
for (int i = 0;i < 20; i++)
    
{
        num
++;
        cout
<<num<<endl;
    }
    

    EXIT_LFS_LOCK_;

}
 



int _tmain(int argc, _TCHAR* argv[])
{
    HANDLE hThrd[
4];

    DWORD dwThrdID[
4];
    hThrd[
0= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Func1, NULL, 0&dwThrdID[0]);
    hThrd[
1= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Func1, NULL, 0&dwThrdID[1]);
    hThrd[
2= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Func1, NULL, 0&dwThrdID[2]);
    hThrd[
3= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Func1, NULL, 0&dwThrdID[3]);

    WaitForMultipleObjects(
4, hThrd, TRUE, INFINITE);
    
for (int i=0;i<4;i++)
    
{
        CloseHandle(hThrd[i]);
    }


    system(
"pause");
    
return 0;
}


]]>
Thread Synchronization 綰跨▼鍚屾http://m.shnenglu.com/huangyi5209/articles/141190.htmlhuangyi5209huangyi5209Sun, 06 Mar 2011 01:26:00 GMThttp://m.shnenglu.com/huangyi5209/articles/141190.htmlhttp://m.shnenglu.com/huangyi5209/comments/141190.htmlhttp://m.shnenglu.com/huangyi5209/articles/141190.html#Feedback0http://m.shnenglu.com/huangyi5209/comments/commentRss/141190.htmlhttp://m.shnenglu.com/huangyi5209/services/trackbacks/141190.html
#include <windows.h>
#include 
<iostream>

using namespace std;

static int g_n;
CRITICAL_SECTION m_cs;

UINT ThreadOne(LPVOID lParam)
{
    EnterCriticalSection(
&m_cs);

    
for (int i = 0; i < 10; i++)
    
{
        g_n
++;
        cout
<<"Thread 1:"<<g_n<<"\n";
    }

    LeaveCriticalSection(
&m_cs);
    
return 0;
}


UINT ThreadTwo(LPVOID lParam)
{
    EnterCriticalSection(
&m_cs);

    
for (int i = 0; i < 10; i++)
    
{
        g_n
++;
        cout
<<"Thread 2:"<<g_n<<"\n";
    }

    LeaveCriticalSection(
&m_cs);
    
return 0;
}


int main()
{
    HANDLE hThrd[
2];
    DWORD IDThread1,IDThread2;

    InitializeCriticalSection(
&m_cs);
    
    hThrd[
0= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadOne, (LPVOID)NULL, 0&IDThread1);
    hThrd[
1= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadTwo, (LPVOID)NULL, 0&IDThread1);

    WaitForMultipleObjects(
2, hThrd, TRUE, INFINITE);
    DeleteCriticalSection(
&m_cs);

    system(
"pause");
    
return 0;
}

綰跨▼鍚屾(for MFC)
#include "win32_mfc.h"
#include 
<afxmt.h>
#include 
<iostream>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// 鍞竴鐨勫簲鐢ㄧ▼搴忓璞?/span>

CWinApp theApp;

using namespace std;

CCriticalSection c_s;
static int g_C;

UINT ThreadFunction1(LPVOID lParam)
{
    CSingleLock 
lock(&c_s);

    
lock.Lock();

    
for (int i = 0; i < 10; i++)
    
{
        g_C
++;
        cout
<<  "Thread 1 : " << g_C << endl;
    }

    
lock.Unlock();
    
return 0;
}


UINT ThreadFunction2(LPVOID lParam)
{
    CSingleLock 
lock(&c_s);

    
lock.Lock();

    
for (int i = 0; i < 10; i++)
    
{
        g_C
++;
        cout
<<  "Thread 2 : " << g_C << endl;
    }

    
lock.Unlock();
    
return 0;
}


int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
    
int nRetCode = 0;

    
// 鍒濆鍖?nbsp;MFC 騫跺湪澶辮觸鏃舵樉紺洪敊璇?/span>
    if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    
{
        
// TODO: 鏇存敼閿欒浠g爜浠ョ鍚堟偍鐨勯渶瑕?/span>
        _tprintf(_T("閿欒: MFC 鍒濆鍖栧け璐n"));
        nRetCode 
= 1;
    }

    
else
    
{
        
// TODO: 鍦ㄦ澶勪負搴旂敤紼嬪簭鐨勮涓虹紪鍐欎唬鐮併?/span>
        CWinThread *Thread[2];
        HANDLE hand[
2];

        Thread[
0= AfxBeginThread(ThreadFunction1, (LPVOID)NULL);
        Thread[
1= AfxBeginThread(ThreadFunction2, (LPVOID)NULL);

        
for (int i = 0; i < 2; i++)
            hand[i] 
= Thread[i]->m_hThread;

        WaitForMultipleObjects(
2, hand, TRUE, INFINITE);
    }


    system(
"pause");
    
return nRetCode;
}




]]>
How to use WIN32 Event Kernel Object 浜嬩歡鍐呮牳瀵硅薄鐨勪嬌鐢?/title><link>http://m.shnenglu.com/huangyi5209/articles/141142.html</link><dc:creator>huangyi5209</dc:creator><author>huangyi5209</author><pubDate>Sat, 05 Mar 2011 00:30:00 GMT</pubDate><guid>http://m.shnenglu.com/huangyi5209/articles/141142.html</guid><wfw:comment>http://m.shnenglu.com/huangyi5209/comments/141142.html</wfw:comment><comments>http://m.shnenglu.com/huangyi5209/articles/141142.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/huangyi5209/comments/commentRss/141142.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/huangyi5209/services/trackbacks/141142.html</trackback:ping><description><![CDATA[<br>鑷姩閲嶇疆浜嬩歡鍐呮牳瀵硅薄<br><br> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #000000">#include </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">stdafx.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">windows.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif">#include </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">iostream</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000"> std;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif">DWORD WINAPI Tf()<br><img id=Codehighlighter1_102_452_Open_Image onclick="this.style.display='none'; Codehighlighter1_102_452_Open_Text.style.display='none'; Codehighlighter1_102_452_Closed_Image.style.display='inline'; Codehighlighter1_102_452_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_102_452_Closed_Image onclick="this.style.display='none'; Codehighlighter1_102_452_Closed_Text.style.display='none'; Codehighlighter1_102_452_Open_Image.style.display='inline'; Codehighlighter1_102_452_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_102_452_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_102_452_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">thread instantiated<img src="http://m.shnenglu.com/Images/dot.gif"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    HANDLE hEvent </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> OpenEvent(EVENT_ALL_ACCESS, FALSE, __T(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">MyEvent</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">hEvent)<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> counter </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; counter </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">; counter</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">char</span><span style="COLOR: #008000"><br><img id=Codehighlighter1_298_377_Open_Image onclick="this.style.display='none'; Codehighlighter1_298_377_Open_Text.style.display='none'; Codehighlighter1_298_377_Closed_Image.style.display='inline'; Codehighlighter1_298_377_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_298_377_Closed_Image onclick="this.style.display='none'; Codehighlighter1_298_377_Closed_Text.style.display='none'; Codehighlighter1_298_377_Open_Image.style.display='inline'; Codehighlighter1_298_377_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif"></span><span style="COLOR: #000000">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_298_377_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_298_377_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        WaitForSingleObject(hEvent, INFINITE);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Got The Single<img src="http://m.shnenglu.com/Images/dot.gif"></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">End of the Thread<img src="http://m.shnenglu.com/Images/dot.gif"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img id=Codehighlighter1_465_1219_Open_Image onclick="this.style.display='none'; Codehighlighter1_465_1219_Open_Text.style.display='none'; Codehighlighter1_465_1219_Closed_Image.style.display='inline'; Codehighlighter1_465_1219_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_465_1219_Closed_Image onclick="this.style.display='none'; Codehighlighter1_465_1219_Closed_Text.style.display='none'; Codehighlighter1_465_1219_Open_Image.style.display='inline'; Codehighlighter1_465_1219_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_465_1219_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_465_1219_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    Create an Auto Reset Event which automatically reset to <br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    Non Signalled state after being signalled</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    HANDLE hEvent </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> CreateEvent(NULL, FALSE, FALSE, __T(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">MyEvent</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">hEvent)<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    DWORD Id;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    HANDLE hThrd </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> CreateThread(NULL, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, (LPTHREAD_START_ROUTINE)Tf, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">Id);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">hThrd)<br><img id=Codehighlighter1_773_813_Open_Image onclick="this.style.display='none'; Codehighlighter1_773_813_Open_Text.style.display='none'; Codehighlighter1_773_813_Closed_Image.style.display='inline'; Codehighlighter1_773_813_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_773_813_Closed_Image onclick="this.style.display='none'; Codehighlighter1_773_813_Closed_Text.style.display='none'; Codehighlighter1_773_813_Open_Image.style.display='inline'; Codehighlighter1_773_813_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_773_813_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_773_813_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         CloseHandle(hThrd);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Wait for a while before continuing<img src="http://m.shnenglu.com/Images/dot.gif">.</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    Sleep(</span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000">);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> counter </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; counter </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">; counter</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br><img id=Codehighlighter1_922_1035_Open_Image onclick="this.style.display='none'; Codehighlighter1_922_1035_Open_Text.style.display='none'; Codehighlighter1_922_1035_Closed_Image.style.display='inline'; Codehighlighter1_922_1035_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_922_1035_Closed_Image onclick="this.style.display='none'; Codehighlighter1_922_1035_Closed_Text.style.display='none'; Codehighlighter1_922_1035_Open_Image.style.display='inline'; Codehighlighter1_922_1035_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_922_1035_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_922_1035_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Signal the event</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        SetEvent(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> wait for some time before giving another signal</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        Sleep(</span><span style="COLOR: #000000">2000</span><span style="COLOR: #000000">);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Wait for the Thread to Die</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    WaitForSingleObject(hThrd, INFINITE);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hThrd);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    <br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">End of Main <img src="http://m.shnenglu.com/Images/dot.gif"><img src="http://m.shnenglu.com/Images/dot.gif">..</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div> <br>鎵嬪姩閲嶇疆浜嬩歡鍐呮牳瀵硅薄<br> <div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #000000">DWORD WINAPI Tf()<br><img id=Codehighlighter1_18_465_Open_Image onclick="this.style.display='none'; Codehighlighter1_18_465_Open_Text.style.display='none'; Codehighlighter1_18_465_Closed_Image.style.display='inline'; Codehighlighter1_18_465_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_18_465_Closed_Image onclick="this.style.display='none'; Codehighlighter1_18_465_Closed_Text.style.display='none'; Codehighlighter1_18_465_Open_Image.style.display='inline'; Codehighlighter1_18_465_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_18_465_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_18_465_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">thread instantiated<img src="http://m.shnenglu.com/Images/dot.gif"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    HANDLE hEvent </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> OpenEvent(EVENT_ALL_ACCESS, FALSE, __T(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">MyEvent</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">hEvent)<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> counter </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; counter </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">; counter</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">) </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">char</span><span style="COLOR: #008000"><br><img id=Codehighlighter1_214_390_Open_Image onclick="this.style.display='none'; Codehighlighter1_214_390_Open_Text.style.display='none'; Codehighlighter1_214_390_Closed_Image.style.display='inline'; Codehighlighter1_214_390_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_214_390_Closed_Image onclick="this.style.display='none'; Codehighlighter1_214_390_Closed_Text.style.display='none'; Codehighlighter1_214_390_Open_Image.style.display='inline'; Codehighlighter1_214_390_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif"></span><span style="COLOR: #000000">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_214_390_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_214_390_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        WaitForSingleObject(hEvent, INFINITE);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> We need to reset the event since the event is manual reset<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    event</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        ResetEvent(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Got The Single<img src="http://m.shnenglu.com/Images/dot.gif"></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">End of the Thread<img src="http://m.shnenglu.com/Images/dot.gif"><img src="http://m.shnenglu.com/Images/dot.gif"></span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img id=Codehighlighter1_478_1221_Open_Image onclick="this.style.display='none'; Codehighlighter1_478_1221_Open_Text.style.display='none'; Codehighlighter1_478_1221_Closed_Image.style.display='inline'; Codehighlighter1_478_1221_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_478_1221_Closed_Image onclick="this.style.display='none'; Codehighlighter1_478_1221_Closed_Text.style.display='none'; Codehighlighter1_478_1221_Open_Image.style.display='inline'; Codehighlighter1_478_1221_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif"></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> main()</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_478_1221_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_478_1221_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    Create an Manual Reset Event where events must be reset <br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">    manually to non signalled state</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    HANDLE hEvent </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> CreateEvent(NULL, TRUE, FALSE, __T(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">MyEvent</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">));<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">hEvent)<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    DWORD Id;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    HANDLE hThrd </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> CreateThread(NULL, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, (LPTHREAD_START_ROUTINE)Tf, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">Id);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">hThrd)<br><img id=Codehighlighter1_775_815_Open_Image onclick="this.style.display='none'; Codehighlighter1_775_815_Open_Text.style.display='none'; Codehighlighter1_775_815_Closed_Image.style.display='inline'; Codehighlighter1_775_815_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_775_815_Closed_Image onclick="this.style.display='none'; Codehighlighter1_775_815_Closed_Text.style.display='none'; Codehighlighter1_775_815_Open_Image.style.display='inline'; Codehighlighter1_775_815_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_775_815_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_775_815_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         CloseHandle(hThrd);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Wait for a while before continuing<img src="http://m.shnenglu.com/Images/dot.gif">.</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    Sleep(</span><span style="COLOR: #000000">1000</span><span style="COLOR: #000000">);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000"> (</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000"> counter </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">; counter </span><span style="COLOR: #000000"><</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">; counter</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">)<br><img id=Codehighlighter1_924_1037_Open_Image onclick="this.style.display='none'; Codehighlighter1_924_1037_Open_Text.style.display='none'; Codehighlighter1_924_1037_Closed_Image.style.display='inline'; Codehighlighter1_924_1037_Closed_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_924_1037_Closed_Image onclick="this.style.display='none'; Codehighlighter1_924_1037_Closed_Text.style.display='none'; Codehighlighter1_924_1037_Open_Image.style.display='inline'; Codehighlighter1_924_1037_Open_Text.style.display='inline';" align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif">    </span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_924_1037_Closed_Text><img src="http://m.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_924_1037_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Signal the event</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        SetEvent(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> wait for some time before giving another signal</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        Sleep(</span><span style="COLOR: #000000">2000</span><span style="COLOR: #000000">);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> Wait for the Thread to Die</span><span style="COLOR: #008000"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    WaitForSingleObject(hThrd, INFINITE);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hThrd);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    <br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    cout</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">End of Main <img src="http://m.shnenglu.com/Images/dot.gif"><img src="http://m.shnenglu.com/Images/dot.gif">..</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><<</span><span style="COLOR: #000000">endl;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    system(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">pause</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img align=top src="http://m.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div> <img src ="http://m.shnenglu.com/huangyi5209/aggbug/141142.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/huangyi5209/" target="_blank">huangyi5209</a> 2011-03-05 08:30 <a href="http://m.shnenglu.com/huangyi5209/articles/141142.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>ASCII 杞?UNICODEhttp://m.shnenglu.com/huangyi5209/articles/141141.htmlhuangyi5209huangyi5209Fri, 04 Mar 2011 23:57:00 GMThttp://m.shnenglu.com/huangyi5209/articles/141141.htmlhttp://m.shnenglu.com/huangyi5209/comments/141141.htmlhttp://m.shnenglu.com/huangyi5209/articles/141141.html#Feedback0http://m.shnenglu.com/huangyi5209/comments/commentRss/141141.htmlhttp://m.shnenglu.com/huangyi5209/services/trackbacks/141141.html 

wchar_t *ascii_to_unicode(const char *resource)
{
    
const char* sp;
    wchar_t
* result, *rp;
     unsigned length 
= strlen(resource) + 1;
     
if (!resource)
         
return NULL;
    
     result 
= (wchar_t*)malloc(length * sizeof(wchar_t));
     
if (result)
     
{
         
for (sp = resource, rp = result; *sp; sp++, rp++)
             
*rp = *sp;
         
*rp = 0;
     }


     
return result;
}


int main(){
    
char ch[] = "C:\\data\\\\test230.ext";
    wchar_t
* wchr = ascii_to_unicode(ch);

    free(wchr);
    system(
"pause");
    
return 0;
}


]]>
鍖哄垎C++鐨勬寚閽堝拰寮曠敤http://m.shnenglu.com/huangyi5209/articles/139240.htmlhuangyi5209huangyi5209Mon, 24 Jan 2011 12:29:00 GMThttp://m.shnenglu.com/huangyi5209/articles/139240.htmlhttp://m.shnenglu.com/huangyi5209/comments/139240.htmlhttp://m.shnenglu.com/huangyi5209/articles/139240.html#Feedback0http://m.shnenglu.com/huangyi5209/comments/commentRss/139240.htmlhttp://m.shnenglu.com/huangyi5209/services/trackbacks/139240.htmlPointers and references look different enough (pointers use the “*” and “->” operators, references use “.“), but they seem to do similar things. Both pointers and references let you refer to other objects indirectly. How, then, do you decide when to use one and not the other?

First, recognize that there is no such thing as a null reference. A reference must always refer to some object. As a result, if you have a variable whose purpose is to refer to another object, but it is possible that there might not be an object to refer to, you should make the variable a pointer, because then you can set it to null. On the other hand, if the variable must alwaysrefer to an object, i.e., if your design does not allow for the possibility that the variable is null, you should probably make the variable a reference.

“But wait,” you wonder, “what about underhandedness like this?”

  1. char *pc = 0;          // set pointer to null   
  2. char& rc = *pc;        // make reference refer to   
  3.                        // dereferenced null pointer  

Well, this is evil, pure and simple. The results are undefined (compilers can generate output to do anything they like), and people who write this kind of code should be shunned until they agree to cease and desist. If you have to worry about things like this in your software, you’re probably best off avoiding references entirely. Either that or finding a better class of programmers to work with. We’ll henceforth ignore the possibility that a reference can be “null.”

Because a reference must refer to an object, C++ requires that references be initialized:

string& rs;             // error! References must   
  1.                         // be initialized   
  2. string s("xyzzy");   
  3. string& rs = s;         // okay, rs refers to s  

Pointers are subject to no such restriction:

  1. string *ps;             // uninitialized pointer:   
  2.                         // valid but risky  

The fact that there is no such thing as a null reference implies that it can be more efficient to use references than to use pointers. That’s because there’s no need to test the validity of a reference before using it:

void printDouble(const double& rd)   
  1. {   
  2.     cout << rd;         // no need to test rd; it   
  3. }                       // must refer to a double  

Pointers, on the other hand, should generally be tested against null:

  1. void printDouble(const double *pd)   
  2. {   
  3. if (pd) {             // check for null pointer   
  4. cout << *pd;   
  5. }   
  6. }  

Another important difference between pointers and references is that pointers may be reassigned to refer to different objects. A reference, however, always refers to the object with which it is initialized:

  1. string s1("Nancy");   
  2. string s2("Clancy");   
  3. string& rs = s1;         // rs refers to s1   
  4.   
  5. string *ps = &s1;        // ps points to s1<A name=31186></A>   
  6.   
  7. rs = s2;                 // rs still refers to s1,   
  8.                          // but s1's value is now   
  9.                          // "Clancy"   
  10.   
  11. ps = &s2;                // ps now points to s2;   
  12.                          // s1 is unchanged  

In general, you should use a pointer whenever you need to take into account the possibility that there’s nothing to refer to (in which case you can set the pointer to null) or whenever you need to be able to refer to different things at different times (in which case you can change where the pointer points). You should use a reference whenever you know there will always be an object to refer to and you also know that once you’re referring to that object, you’ll never want to refer to anything else.

References, then, are the feature of choice when you know you have something to refer to, when you’ll never want to refer to anything else, and when implementing operators whose syntactic requirements make the use of pointers undesirable. In all other cases, stick with pointers.



]]>
Callback Functions Tutorial - C++鐨勫洖璋冨嚱鏁版満鍒?/title><link>http://m.shnenglu.com/huangyi5209/articles/139239.html</link><dc:creator>huangyi5209</dc:creator><author>huangyi5209</author><pubDate>Mon, 24 Jan 2011 12:26:00 GMT</pubDate><guid>http://m.shnenglu.com/huangyi5209/articles/139239.html</guid><wfw:comment>http://m.shnenglu.com/huangyi5209/comments/139239.html</wfw:comment><comments>http://m.shnenglu.com/huangyi5209/articles/139239.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/huangyi5209/comments/commentRss/139239.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/huangyi5209/services/trackbacks/139239.html</trackback:ping><description><![CDATA[<div class="hvzpftn" id="display_content" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; "><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Introduction</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If you are reading this article, you probably wonder what callback functions are. This article explains what callback functions are, what are they good for, why you should use them, and so forth. However, before learning what callback functions are, you must be familiar with function pointers. If you aren't, consult a C/C++ book or consider reading the following:</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">The Syntax of C and C++ Function Pointers</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Pointers to member functions</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Declaring, Assigning, and Using Function Pointers</a></li></ul><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">What Is a Callback Function?</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">The simple answer to this first question is that a callback function is a function that is called through a function pointer. If you pass the pointer (address) of a function as an argument to another, when that pointer is used to call the function it points to it is said that a call back is made.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Why Should You Use Callback Functions?</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Because they uncouple the caller from the callee. The caller doesn't care who the callee is; all it knows is that there is a callee with a certain prototype and probably some restriction (for instance, the returned value can be int, but certain values have certain meanings).</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If you are wondering how is that useful in practice, imagine that you want to write a library that provides implementation for sorting algorithms (yes, that is pretty classic), such as bubble sort, shell short, shake sort, quick sort, and others. The catch is that you don't want to embed the sorting logic (which of two elements goes first in an array) into your functions, making your library more general to use. You want the client to be responsible to that kind of logic. Or, you want it to be used for various data types (ints, floats, strings, and so on). So, how do you do it? You use function pointers and make callbacks.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">A callback can be used for notifications. For instance, you need to set a timer in your application. Each time the timer expires, your application must be notified. But, the implementer of the time'rs mechanism doesn't know anything about your application. It only wants a pointer to a function with a given prototype, and in using that pointer it makes a callback, notifying your application about the event that has occurred. Indeed, the SetTimer() WinAPI uses a callback function to notify that the timer has expired (and, in case there is no callback function provided, it posts a message to the application's queue).</p><div id="hvzpftn" class="toolbox noBullets colRight" style="margin-top: 15px; margin-right: 0px; margin-bottom: 5px; margin-left: 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; float: right; width: 160px; border-left-color: rgb(204, 204, 204); font-size: 11px; clear: both; "><ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 5px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 5px; "><li id="hvzpftn" class="comment_linky" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 25px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/icon_comment.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 50%; background-repeat: no-repeat no-repeat; "><a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; "><nobr>Post a comment</nobr></a></li><li id="hvzpftn" class="email" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 25px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/icon_email.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 50%; background-repeat: no-repeat no-repeat; "><a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; ">Email Article</a></li><li id="hvzpftn" class="print" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 25px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/icon_print.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 50%; background-repeat: no-repeat no-repeat; "><a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; ">Print Article</a></li><li id="toolBoxShareMenu" class="share" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: -12px; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 12px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/share_article-bg.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; z-index: 100; position: relative; background-position: 0px -1000px; background-repeat: no-repeat no-repeat; "><img height="16" width="16" class="icon" alt="" src="http://www.codeguru.com/newimg/images/icon_share.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: middle; margin-top: 0px; margin-right: 5px; margin-bottom: 2px; margin-left: 0px; "> <a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; ">Share Articles</a><img src="http://www.codeguru.com/newimg/images/arrow_down_spblue.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: middle; margin-top: 0px; margin-right: 5px; margin-bottom: 2px; margin-left: 0px; "></li></ul></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Another example from WinAPI functions that use callback mechanism is EnumWindow(), which enumerates all the top-level windows on the screen. EnumWindow() iterates over the top-level windows, calling an application-provided function for each window, passing the handler of the window. If the callee returns a value, the iteration continues; otherwise, it stops. EnumWindows() just doesn't care where the callee is and what it does with the handler it passes over. It is only interested in the return value, because based on that it continues its execution or not.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">However, callback functions are inherited from C. Thus, in C++, they should be only used for interfacing C code and existing callback interfaces. Except for these situations, you should use virtual methods or functors, not callback functions.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">A Simple Implementation Example</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Now, follow the example that can be found in the attached files. I have created a dynamic linked library called sort.dll. It exports a type called CompareFunction:</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">typedef int (__stdcall *CompareFunction)(const byte*, const byte*);</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">which will be the type of your callback functions. It also exports two methods, called Bubblesort() and Quicksort(), which have the same prototype but provide different behavior by implementing the sorting algorithms with the same name.</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">void DLLDIR __stdcall Bubblesort(byte* array, int size, int elem_size, CompareFunction cmpFunc); void DLLDIR __stdcall Quicksort(byte* array, int size, int elem_size, CompareFunction cmpFunc); </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">These two functions take the following parameters:</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>byte* array</em>: a pointer to an array of elements (doesn't matter of which type)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>int size</em>: the number of elements in the array</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>int elem_size</em>: the size, in bytes, of an element of the array</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>CompareFunction cmpFunc</em>: a pointer to a callback function with the prototype listed above</li></ul><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">The implementation of these two functions performs a sorting of the array. But, each time there is a need to decide which of two elements goes first, a callback is made to the function whose address was passed as an argument. For the library writer, it doesn't matter where that function is implemented, or how it is implemented. All that matters it is that it takes the address of two elements (that are the two be compared) and it returns one of the following values (this is a contract between the library developers and its clients):</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; ">-1: if the first element is lesser and/or should go before the second element (in a sorted array)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; ">0: if the two elements are equal and/or their relative position doesn't matter (each one can go before the other in a sorted array)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; ">1: if the first element is greater and/or should go after the second element (in a sorted array)</li></ul><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">With this contract explicitly stated, the implementation of the Bubblesort() function is this (for Quicksort(), which a little bit more complicated, see the attached files).</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">void DLLDIR __stdcall Bubblesort(byte* array, int size, int elem_size, CompareFunction cmpFunc) { for(int i=0; i < size; i++) { for(int j=0; j < size-1; j++) { // make the callback to the comparison function if(1 == (*cmpFunc)(array+j*elem_size, array+(j+1)*elem_size)) { // the two compared elements must be interchanged byte* temp = new byte[elem_size]; memcpy(temp, array+j*elem_size, elem_size); memcpy(array+j*elem_size, array+(j+1)*elem_size, elem_size); memcpy(array+(j+1)*elem_size, temp, elem_size); delete [] temp; } } } } </pre><blockquote style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong>Note</strong>: Because the implementation uses memcpy(), these library functions should not be used for types other than POD (Plain-Old-Data).</blockquote><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">On the client side, there must be a callback function whose address is to be passed to the Bubblesort() function. As a simple example, I have written a function that compares two integer values and one that compares two strings:</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">int __stdcall CompareInts(const byte* velem1, const byte* velem2) { int elem1 = *(int*)velem1; int elem2 = *(int*)velem2; if(elem1 < elem2) return -1; if(elem1 > elem2) return 1; return 0; } int __stdcall CompareStrings(const byte* velem1, const byte* velem2) { const char* elem1 = (char*)velem1; const char* elem2 = (char*)velem2; return strcmp(elem1, elem2); } </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">To put all these to a test, I have written this short program. It passes an array with five elements to Bubblesort() or Quicksort() along with the pointer to the callback functions.</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">int main(int argc, char* argv[]) { int i; int array[] = {5432, 4321, 3210, 2109, 1098}; cout << "Before sorting ints with Bubblesort\n"; for(i=0; i < 5; i++) cout << array[i] << '\n'; Bubblesort((byte*)array, 5, sizeof(array[0]), &CompareInts); cout << "After the sorting\n"; for(i=0; i < 5; i++) cout << array[i] << '\n'; const char str[5][10] = {"estella", "danielle", "crissy", "bo", "angie"}; cout << "Before sorting strings with Quicksort\n"; for(i=0; i < 5; i++) cout << str[i] << '\n'; Quicksort((byte*)str, 5, 10, &CompareStrings); cout << "After the sorting\n"; for(i=0; i < 5; i++) cout << str[i] << '\n'; return 0; } </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If I decide that I want the sorting to be done descending (with the biggest element first), all I have to do is to change the callback function code, or provide another that implements the desired logic.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Calling Conventions</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">In the above code, you can see the word <em>__stdcall</em> in the function's prototype. Because it starts with a double underscore, it is, of course, a compiler-specific extension, more exactly a Microsoft-specific one. Any compiler that supports development of Win32-based applications must support this or an equivalent one. A function that is marked with <em>__stdcall</em> uses the standard calling convention so named because all Win32 API functions (except the few that take variable arguments) use it. Functions that follow the standard calling convention remove the parameters from the stack before they return to the caller. This is the standard convention for Pascal. But in C/C++, the calling convention is that the caller cleans up the stack instead of the called function. To enforce that a function uses the C/C++ calling convention, <em>__cdecl</em>must be used. Variable argument functions use the C/C++ calling convention.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Windows adopted the standard calling convention (Pascal convention) because it reduces the size of the code. This was very important in the early days of Windows, when it ran on systems with 640 KB RAM.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If you don't like the word <em>__stdcall</em>, you can use the <strong>CALLBACK</strong> macro, defined in windef.h, as</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">#define CALLBACK __stdcall</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">or</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">#define CALLBACK PASCAL</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">where PASCAL is #defined as __stdcall.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">You can read more about calling convention here: <a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Calling Convetions in Microsoft Visual C++</a>.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">C++ Methods as Callback Functions</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Because you probably write in C++, you want your callback function a method of a class. But, if you try this:</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">class CCallbackTester { public: int CALLBACK CompareInts(const byte* velem1, const byte* velem2); }; Bubblesort((byte*)array, 5, sizeof(array[0]), &CCallbackTester::CompareInts); </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">with a MS compiler, you get this compilation error:</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; "><em>error C2664: 'Bubblesort' : cannot convert parameter 4 from 'int (__stdcall CCallbackTester::*)(const unsigned char *,const unsigned char *)' to 'int (__stdcall *)(const unsigned char *,const unsigned char *)' There is no context in which this conversion is possible</em></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">That happens because non-static member functions have an additional parameter, pointer <em>this</em> (see this<a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">FAQ</a> for more).</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">That obliges you to make the member function static. If that's not acceptable, you can use several techniques to overcome that. Check the following links to learn more.</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">How to Implement Callbacks in C and C++</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">C++ Callback Demo</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Callbacks in C++ Using Template Functors</a></li></ul><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Notices</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">The attached files contain two projects. <em>SortingDLL</em> is a Win32 DLL project. The sort.dll output library exports the two sorting functions, Bubblesort() and Quicksort(). The second project, <em>SortDemo</em>, is a Win32 Console Application that demonstrates how to use the sort.dll library. The output directory for both projects is <em>Shared</em> directory, where the following files can be found: sort.h, sort.dll, sort.lib, and SortDemo.exe.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Further References</h3><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">C++ OO Callback Technique</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Function Pointers to Non-Static Object Methods</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Pointers and References</a></li></ul></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; font-weight: bold; color: rgb(0, 0, 63); line-height: 1.5em; font-family: Arial, Helvetica, sans-serif; ">About the Author</h2><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; ">Marius Bancila is a Microsoft MVP for VC++. He works as a software developer for a Norwegian-based company. He is mainly focused on building desktop applications with MFC and VC#. He keeps a blog at www.mariusbancila.ro/blog, focused on Windows programming. He is the co-founder of codexpert.ro, a community for Romanian C++/VC++ programmers.<br style="font-size: 12px; line-height: 1em; "><br style="font-size: 12px; line-height: 1em; "></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; font-weight: bold; color: rgb(0, 0, 63); line-height: 1.5em; font-family: Arial, Helvetica, sans-serif; ">Downloads</h2><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; "><a style="color: rgb(5, 48, 97); text-decoration: underline !important; ">callbacks.zip</a></li> <img src ="http://m.shnenglu.com/huangyi5209/aggbug/139239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/huangyi5209/" target="_blank">huangyi5209</a> 2011-01-24 20:26 <a href="http://m.shnenglu.com/huangyi5209/articles/139239.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <a href="http://m.shnenglu.com/">青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品</a> <div style="position:fixed;left:-9000px;top:-9000px;"><font id="pjuwb"></font><button id="pjuwb"><pre id="pjuwb"></pre></button><sub id="pjuwb"></sub><tbody id="pjuwb"><var id="pjuwb"><address id="pjuwb"></address></var></tbody><listing id="pjuwb"><label id="pjuwb"><strong id="pjuwb"></strong></label></listing><wbr id="pjuwb"><small id="pjuwb"><tbody id="pjuwb"></tbody></small></wbr><ins id="pjuwb"><xmp id="pjuwb"></xmp></ins><style id="pjuwb"></style><label id="pjuwb"><em id="pjuwb"><li id="pjuwb"></li></em></label><samp id="pjuwb"></samp><menu id="pjuwb"><input id="pjuwb"></input></menu><pre id="pjuwb"><tbody id="pjuwb"><tfoot id="pjuwb"><button id="pjuwb"></button></tfoot></tbody></pre><form id="pjuwb"></form><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"><sup id="pjuwb"></sup></label></style></i><li id="pjuwb"><table id="pjuwb"><abbr id="pjuwb"></abbr></table></li><video id="pjuwb"></video><dfn id="pjuwb"></dfn><progress id="pjuwb"></progress><strong id="pjuwb"></strong><mark id="pjuwb"></mark><em id="pjuwb"></em><tbody id="pjuwb"><p id="pjuwb"><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike></p></tbody><option id="pjuwb"></option><strike id="pjuwb"></strike><u id="pjuwb"></u><td id="pjuwb"><center id="pjuwb"><tr id="pjuwb"></tr></center></td><em id="pjuwb"><mark id="pjuwb"><em id="pjuwb"><tt id="pjuwb"></tt></em></mark></em><strong id="pjuwb"></strong><wbr id="pjuwb"></wbr><s id="pjuwb"></s><strong id="pjuwb"></strong><legend id="pjuwb"></legend><nav id="pjuwb"></nav><dl id="pjuwb"><th id="pjuwb"><dl id="pjuwb"></dl></th></dl><noframes id="pjuwb"><ins id="pjuwb"></ins></noframes><font id="pjuwb"></font><strike id="pjuwb"><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"></label></style></i></strike><output id="pjuwb"></output><thead id="pjuwb"><pre id="pjuwb"></pre></thead><source id="pjuwb"></source><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem><pre id="pjuwb"><span id="pjuwb"><pre id="pjuwb"><big id="pjuwb"></big></pre></span></pre><cite id="pjuwb"><fieldset id="pjuwb"><s id="pjuwb"><rt id="pjuwb"></rt></s></fieldset></cite><big id="pjuwb"><progress id="pjuwb"><big id="pjuwb"></big></progress></big><samp id="pjuwb"><delect id="pjuwb"></delect></samp><dl id="pjuwb"></dl><strike id="pjuwb"><nav id="pjuwb"><dl id="pjuwb"><strong id="pjuwb"></strong></dl></nav></strike><tbody id="pjuwb"><b id="pjuwb"><optgroup id="pjuwb"><rp id="pjuwb"></rp></optgroup></b></tbody><em id="pjuwb"></em><xmp id="pjuwb"><blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote></xmp> <i id="pjuwb"><abbr id="pjuwb"><i id="pjuwb"><abbr id="pjuwb"></abbr></i></abbr></i><center id="pjuwb"><acronym id="pjuwb"><center id="pjuwb"></center></acronym></center><pre id="pjuwb"></pre><ul id="pjuwb"><thead id="pjuwb"></thead></ul><blockquote id="pjuwb"><pre id="pjuwb"><sup id="pjuwb"></sup></pre></blockquote><acronym id="pjuwb"></acronym><big id="pjuwb"><s id="pjuwb"></s></big><th id="pjuwb"></th><th id="pjuwb"></th><tbody id="pjuwb"></tbody><thead id="pjuwb"><strike id="pjuwb"></strike></thead><th id="pjuwb"><dl id="pjuwb"><wbr id="pjuwb"></wbr></dl></th><dl id="pjuwb"><strong id="pjuwb"></strong></dl><abbr id="pjuwb"><noframes id="pjuwb"><noscript id="pjuwb"></noscript></noframes></abbr><td id="pjuwb"><ol id="pjuwb"></ol></td><li id="pjuwb"><noscript id="pjuwb"><abbr id="pjuwb"></abbr></noscript></li><small id="pjuwb"><bdo id="pjuwb"><nav id="pjuwb"></nav></bdo></small><style id="pjuwb"></style><optgroup id="pjuwb"><table id="pjuwb"></table></optgroup><center id="pjuwb"><tr id="pjuwb"><dfn id="pjuwb"></dfn></tr></center><th id="pjuwb"></th><u id="pjuwb"></u><tfoot id="pjuwb"><legend id="pjuwb"><i id="pjuwb"></i></legend></tfoot><mark id="pjuwb"></mark><meter id="pjuwb"></meter><nav id="pjuwb"></nav><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><nobr id="pjuwb"></nobr><sub id="pjuwb"><th id="pjuwb"><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem></th></sub><thead id="pjuwb"><sub id="pjuwb"></sub></thead><ul id="pjuwb"><address id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></address></ul><dfn id="pjuwb"></dfn><pre id="pjuwb"></pre><input id="pjuwb"><cite id="pjuwb"><fieldset id="pjuwb"></fieldset></cite></input><u id="pjuwb"><form id="pjuwb"><u id="pjuwb"></u></form></u><kbd id="pjuwb"><em id="pjuwb"><mark id="pjuwb"></mark></em></kbd><tr id="pjuwb"></tr><del id="pjuwb"><form id="pjuwb"><address id="pjuwb"></address></form></del><tfoot id="pjuwb"><legend id="pjuwb"><ol id="pjuwb"><dl id="pjuwb"></dl></ol></legend></tfoot><menu id="pjuwb"><nobr id="pjuwb"><th id="pjuwb"><nobr id="pjuwb"></nobr></th></nobr></menu><fieldset id="pjuwb"></fieldset><pre id="pjuwb"><blockquote id="pjuwb"><samp id="pjuwb"></samp></blockquote></pre><xmp id="pjuwb"><sup id="pjuwb"><pre id="pjuwb"></pre></sup></xmp><span id="pjuwb"><progress id="pjuwb"></progress></span><font id="pjuwb"></font><var id="pjuwb"><abbr id="pjuwb"></abbr></var><strong id="pjuwb"><label id="pjuwb"><i id="pjuwb"><legend id="pjuwb"></legend></i></label></strong><tr id="pjuwb"><em id="pjuwb"><em id="pjuwb"><output id="pjuwb"></output></em></em></tr><thead id="pjuwb"><strike id="pjuwb"></strike></thead> <acronym id="pjuwb"></acronym><i id="pjuwb"></i><tt id="pjuwb"></tt><rt id="pjuwb"><source id="pjuwb"><rt id="pjuwb"></rt></source></rt><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike><del id="pjuwb"></del><font id="pjuwb"><output id="pjuwb"><ins id="pjuwb"><output id="pjuwb"></output></ins></output></font><kbd id="pjuwb"><tr id="pjuwb"><kbd id="pjuwb"></kbd></tr></kbd><pre id="pjuwb"><sup id="pjuwb"><delect id="pjuwb"><samp id="pjuwb"></samp></delect></sup></pre><samp id="pjuwb"></samp><track id="pjuwb"></track><tr id="pjuwb"></tr><center id="pjuwb"></center><fieldset id="pjuwb"></fieldset><i id="pjuwb"></i><td id="pjuwb"></td><rt id="pjuwb"></rt><object id="pjuwb"></object><pre id="pjuwb"><progress id="pjuwb"><sub id="pjuwb"><thead id="pjuwb"></thead></sub></progress></pre><kbd id="pjuwb"><tr id="pjuwb"><option id="pjuwb"></option></tr></kbd><output id="pjuwb"><ins id="pjuwb"></ins></output><ol id="pjuwb"></ol><source id="pjuwb"></source><strong id="pjuwb"></strong><ruby id="pjuwb"></ruby><sub id="pjuwb"><meter id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></meter></sub><pre id="pjuwb"></pre><center id="pjuwb"></center><tr id="pjuwb"><tbody id="pjuwb"><xmp id="pjuwb"><dd id="pjuwb"></dd></xmp></tbody></tr><video id="pjuwb"></video><pre id="pjuwb"></pre><form id="pjuwb"><optgroup id="pjuwb"></optgroup></form><samp id="pjuwb"></samp><kbd id="pjuwb"></kbd><strong id="pjuwb"><option id="pjuwb"></option></strong><object id="pjuwb"></object><abbr id="pjuwb"><noframes id="pjuwb"><abbr id="pjuwb"></abbr></noframes></abbr><ul id="pjuwb"><del id="pjuwb"><button id="pjuwb"><pre id="pjuwb"></pre></button></del></ul><abbr id="pjuwb"></abbr><strong id="pjuwb"><code id="pjuwb"><strong id="pjuwb"></strong></code></strong><option id="pjuwb"></option><optgroup id="pjuwb"><bdo id="pjuwb"><code id="pjuwb"></code></bdo></optgroup><mark id="pjuwb"><em id="pjuwb"><font id="pjuwb"></font></em></mark><acronym id="pjuwb"><code id="pjuwb"></code></acronym><dl id="pjuwb"></dl><em id="pjuwb"></em><object id="pjuwb"><input id="pjuwb"><object id="pjuwb"></object></input></object><output id="pjuwb"><dd id="pjuwb"></dd></output><option id="pjuwb"><button id="pjuwb"><option id="pjuwb"></option></button></option><small id="pjuwb"></small></div> <a href="http://aberyco.com" target="_blank">久久精品亚洲热</a>| <a href="http://jilcool.com" target="_blank">久久综合网色—综合色88</a>| <a href="http://www-n77.com" target="_blank">欧美顶级少妇做爰</a>| <a href="http://555134.com" target="_blank">久久久免费精品</a>| <a href="http://by4672.com" target="_blank">亚洲国产精品999</a>| <a href="http://njggmy.com" target="_blank">欧美高清视频在线观看</a>| <a href="http://goutoujunshi.com" target="_blank">老司机aⅴ在线精品导航</a>| <a href="http://xianconnector.com" target="_blank">亚洲国产欧美日韩</a>| <a href="http://ktt2048.com" target="_blank">亚洲韩日在线</a>| <a href="http://833816.com" target="_blank">欧美先锋影音</a>| <a href="http://5555547.com" target="_blank">久久国产精品99国产</a>| <a href="http://miaoxp.com" target="_blank">欧美伊人久久大香线蕉综合69</a>| <a href="http://339871.com" target="_blank">国产日韩一区二区三区</a>| <a href="http://72nnnn.com" target="_blank">老牛嫩草一区二区三区日本</a>| <a href="http://shruhan.com" target="_blank">麻豆国产精品va在线观看不卡</a>| <a href="http://www40255.com" target="_blank">91久久综合</a>| <a href="http://954k.com" target="_blank">亚洲小视频在线观看</a>| <a href="http://127mingdao.com" target="_blank">国产日韩欧美一区二区</a>| <a href="http://012492.com" target="_blank">久久综合中文</a>| <a href="http://aqxiangtai.com" target="_blank">欧美日韩国产三级</a>| <a href="http://4379d.com" target="_blank">久久国内精品视频</a>| <a href="http://7171152.com" target="_blank">美国成人直播</a>| <a href="http://carboarm.com" target="_blank">欧美一区二区三区免费视频</a>| <a href="http://488918.com" target="_blank">久久久久成人精品</a>| <a href="http://erodasy.com" target="_blank">一区二区三区.www</a>| <a href="http://21bridal.com" target="_blank">久久国产精品久久久久久电车</a>| <a href="http://xxxcalls.com" target="_blank">激情欧美一区二区三区在线观看</a>| <a href="http://59jf.com" target="_blank">欧美激情第4页</a>| <a href="http://www-878009.com" target="_blank">国产精品亚洲网站</a>| <a href="http://oimeal.com" target="_blank">欧美激情亚洲综合一区</a>| <a href="http://8w82.com" target="_blank">国产精品久99</a>| <a href="http://chengli88.com" target="_blank">欧美国产日韩一区</a>| <a href="http://hankanzhan.com" target="_blank">国产精品海角社区在线观看</a>| <a href="http://122332.com" target="_blank">欧美成人精品不卡视频在线观看</a>| <a href="http://123086.com" target="_blank">欧美三区美女</a>| <a href="http://by3259.com" target="_blank">亚洲福利国产</a>| <a href="http://08xxxc.com" target="_blank">精久久久久久久久久久</a>| <a href="http://musicshq.com" target="_blank">日韩视频精品在线</a>| <a href="http://roujizz.com" target="_blank">在线成人免费视频</a>| <a href="http://9238479.com" target="_blank">亚洲与欧洲av电影</a>| <a href="http://submro.com" target="_blank">在线亚洲国产精品网站</a>| <a href="http://aqxiangtai.com" target="_blank">欧美一区二区三区成人</a>| <a href="http://649929.com" target="_blank">一区二区三区四区精品</a>| <a href="http://xw4433.com" target="_blank">久久久久久成人</a>| <a href="http://www901aaa.com" target="_blank">亚洲影院一区</a>| <a href="http://340996.com" target="_blank">欧美日韩另类综合</a>| <a href="http://22400com.com" target="_blank">蜜桃av噜噜一区</a>| <a href="http://78757a.com" target="_blank">国产亚洲日本欧美韩国</a>| <a href="http://tonglijinshu.com" target="_blank">日韩午夜在线播放</a>| <a href="http://chaoporn97.com" target="_blank">亚洲欧洲在线播放</a>| <a href="http://www36633.com" target="_blank">欧美一区二区三区视频</a>| <a href="http://817794.com" target="_blank">亚洲影视在线播放</a>| <a href="http://chaxiangmall.com" target="_blank">欧美aⅴ一区二区三区视频</a>| <a href="http://188293.com" target="_blank">久久久亚洲精品一区二区三区</a>| <a href="http://613609.com" target="_blank">欧美日韩国产美</a>| <a href="http://082235.com" target="_blank">亚洲国产精品成人一区二区</a>| <a href="http://erosgems.com" target="_blank">黄网站免费久久</a>| <a href="http://hnautos.com" target="_blank">新狼窝色av性久久久久久</a>| <a href="http://www-798009.com" target="_blank">亚洲午夜一级</a>| <a href="http://jx963.com" target="_blank">欧美午夜a级限制福利片</a>| <a href="http://xian369.com" target="_blank">欧美成人免费全部</a>| <a href="http://855821.com" target="_blank">精品成人在线观看</a>| <a href="http://1069024.com" target="_blank">久久久久欧美</a>| <a href="http://rxbbei.com" target="_blank">裸体一区二区三区</a>| <a href="http://wwdd44.com" target="_blank">一区在线播放视频</a>| <a href="http://eguge.com" target="_blank">久久精品一本</a>| <a href="http://wwwbaoyu66.com" target="_blank">欧美成人午夜激情</a>| <a href="http://2061851.com" target="_blank">在线免费观看欧美</a>| <a href="http://qiezisp2.com" target="_blank">麻豆国产精品777777在线</a>| <a href="http://05078888.com" target="_blank">欧美91精品</a>| <a href="http://zooxoft.com" target="_blank">亚洲三级国产</a>| <a href="http://www473333.com" target="_blank">欧美日韩亚洲一区在线观看</a>| <a href="http://www13256.com" target="_blank">亚洲国产日韩精品</a>| <a href="http://833077.com" target="_blank">中日韩美女免费视频网址在线观看</a>| <a href="http://678665.com" target="_blank">欧美va亚洲va国产综合</a>| <a href="http://cibocentre.com" target="_blank">亚洲国产成人在线</a>| <a href="http://dv6699.com" target="_blank">一二三区精品福利视频</a>| <a href="http://o3xo.com" target="_blank">欧美手机在线视频</a>| <a href="http://dv6699.com" target="_blank">亚洲一区二区三区免费视频</a>| <a href="http://xhtd688.com" target="_blank">欧美一二三区精品</a>| <a href="http://booyitech.com" target="_blank">国产日韩在线不卡</a>| <a href="http://gg5gg.com" target="_blank">久久天堂成人</a>| <a href="http://xy3977.com" target="_blank">亚洲欧洲三级电影</a>| <a href="http://avtbr123.com" target="_blank">一区二区三区偷拍</a>| <a href="http://1194123.com" target="_blank">国产精品视频</a>| <a href="http://xunlei520.com" target="_blank">久久国内精品视频</a>| <a href="http://yeepey.com" target="_blank">亚洲成色777777女色窝</a>| <a href="http://hbdfgq.com" target="_blank">日韩亚洲精品电影</a>| <a href="http://www-111111.com" target="_blank">国产精品国产三级国产aⅴ9色</a>| <a href="http://1397979.com" target="_blank">艳妇臀荡乳欲伦亚洲一区</a>| <a href="http://www55avav.com" target="_blank">亚洲欧美日韩在线不卡</a>| <a href="http://xwsj2020.com" target="_blank">国产视频一区欧美</a>| <a href="http://www-663345.com" target="_blank">欧美va天堂在线</a>| <a href="http://749996.com" target="_blank">亚洲色诱最新</a>| <a href="http://www-90422.com" target="_blank">裸体素人女欧美日韩</a>| <a href="http://www284tv.com" target="_blank">日韩网站在线</a>| <a href="http://ssss96.com" target="_blank">国产日韩欧美视频在线</a>| <a href="http://555yye.com" target="_blank">免费观看一区</a>| <a href="http://8eeeccc.com" target="_blank">亚洲小视频在线</a>| <a href="http://517hc5.com" target="_blank">欧美激情一区二区三区在线视频</a>| <a href="http://zzmzit.com" target="_blank">99精品欧美</a>| <a href="http://17ccem.com" target="_blank">激情av一区二区</a>| <a href="http://www789yys.com" target="_blank">欧美日韩国产一区精品一区</a>| <a href="http://y87b.com" target="_blank">亚洲欧美制服另类日韩</a>| <a href="http://caox8.com" target="_blank">欧美国产日韩在线</a>| <a href="http://www-82622.com" target="_blank">亚洲欧美中文日韩v在线观看</a>| <a href="http://aaddgg66.com" target="_blank">国产婷婷色一区二区三区四区</a>| <a href="http://cibocentre.com" target="_blank">麻豆精品在线视频</a>| <a href="http://by8556.com" target="_blank">亚洲视频 欧洲视频</a>| <a href="http://xxmh686.com" target="_blank">免费成人在线观看视频</a>| <a href="http://expolucy.com" target="_blank">亚洲一区二区三区乱码aⅴ</a>| <a href="http://vod3366.com" target="_blank">伊人精品成人久久综合软件</a>| <a href="http://b1768.com" target="_blank">欧美日韩三级在线</a>| <a href="http://110673.com" target="_blank">噜噜噜躁狠狠躁狠狠精品视频</a>| <a href="http://obatshaka.com" target="_blank">亚洲精品视频在线观看网站</a>| <a href="http://hhh699.com" target="_blank">毛片av中文字幕一区二区</a>| <a href="http://www49966.com" target="_blank">亚洲私拍自拍</a>| <a href="http://060969.com" target="_blank">亚洲大片在线观看</a>| <a href="http://042225.com" target="_blank">国产伦精品一区二区三区高清版 </a>| <a href="http://www-tt211.com" target="_blank">av不卡在线</a>| <a href="http://yyyy456.com" target="_blank">久久在线免费</a>| <a href="http://337795.com" target="_blank">欧美亚洲色图校园春色</a>| <a href="http://13501680.com" target="_blank">亚洲美女黄色片</a>| <a href="http://xprinter3d.com" target="_blank">伊人狠狠色j香婷婷综合</a>| <a href="http://hnluvlux.com" target="_blank">国产精品盗摄久久久</a>| <a href="http://138128.com" target="_blank">美国十次成人</a>| <a href="http://gztgo.com" target="_blank">久久久青草婷婷精品综合日韩</a>| <a href="http://smdzs.com" target="_blank">亚洲伊人伊色伊影伊综合网</a>| <a href="http://45z6.com" target="_blank">亚洲人成网站在线播</a>| <a href="http://www-440450.com" target="_blank">美女久久一区</a>| <a href="http://www249aaa.com" target="_blank">久久深夜福利</a>| <a href="http://152mu.com" target="_blank">欧美在线视频日韩</a>| <a href="http://hsxinbao.com" target="_blank">亚洲网站啪啪</a>| <a href="http://jy920.com" target="_blank">99精品黄色片免费大全</a>| <a href="http://www-55655.com" target="_blank">亚洲国产精品一区</a>| <a href="http://4kmz.com" target="_blank">在线播放精品</a>| <a href="http://5207877.com" target="_blank">在线免费日韩片</a>| <a href="http://ju255.com" target="_blank">黑人一区二区</a>| <a href="http://xxxxxdywvip18.com" target="_blank">国产一区视频在线看</a>| <a href="http://951738.com" target="_blank">国产精品一区二区三区成人</a>| <a href="http://56lin.com" target="_blank">欧美日韩一视频区二区</a>| <a href="http://iietao.com" target="_blank">欧美日韩午夜在线</a>| <a href="http://wwwxigua66.com" target="_blank">欧美激情精品</a>| <a href="http://322033.com" target="_blank">欧美精品一区二区三区一线天视频</a>| <a href="http://goutoujunshi.com" target="_blank">久久久久一区二区三区</a>| <a href="http://jxjx11.com" target="_blank">久久久久欧美</a>| <a href="http://123-sj.com" target="_blank">老司机久久99久久精品播放免费 </a>| <a href="http://bby99.com" target="_blank">在线亚洲一区观看</a>| <a href="http://www-82622.com" target="_blank">91久久中文</a>| <a href="http://tutu80.com" target="_blank">99视频超级精品</a>| <a href="http://www-4012345.com" target="_blank">aaa亚洲精品一二三区</a>| <a href="http://7555hh.com" target="_blank">亚洲精品一区二区三区婷婷月 </a>| <a href="http://bckxy.com" target="_blank">欧美资源在线观看</a>| <a href="http://pear9.com" target="_blank">欧美一区二区三区成人</a>| <a href="http://124909.com" target="_blank">久久成人国产精品</a>| <a href="http://vipaiqiyi.com" target="_blank">久久久久国色av免费看影院</a>| <a href="http://www218999.com" target="_blank">欧美在线free</a>| <a href="http://snis675.com" target="_blank">麻豆av一区二区三区久久</a>| <a href="http://855821.com" target="_blank">老司机aⅴ在线精品导航</a>| <a href="http://clgtzz.com" target="_blank">麻豆九一精品爱看视频在线观看免费 </a>| <a href="http://yeepey.com" target="_blank">久久久久久有精品国产</a>| <a href="http://5c55c5c.com" target="_blank">快射av在线播放一区</a>| <a href="http://aqdit2022.com" target="_blank">久久综合99re88久久爱</a>| <a href="http://5773000.com" target="_blank">欧美成人网在线</a>| <a href="http://shght.com" target="_blank">欧美系列精品</a>| <a href="http://91pero.com" target="_blank">国内精品久久久久影院薰衣草 </a>| <a href="http://by5130.com" target="_blank">欧美黄色影院</a>| <a href="http://budanbao.com" target="_blank">欧美理论电影在线播放</a>| <a href="http://77mcn.com" target="_blank">国产精品分类</a>| <a href="http://www90aaa.com" target="_blank">红桃视频国产一区</a>| <a href="http://shalxee.com" target="_blank">亚洲人成网站在线播</a>| <a href="http://xsjgxx.com" target="_blank">亚洲影视中文字幕</a>| <a href="http://www218999.com" target="_blank">久久久亚洲欧洲日产国码αv</a>| <a href="http://zb557.com" target="_blank">蜜桃视频一区</a>| <a href="http://9882355.com" target="_blank">一本色道久久综合亚洲精品不卡 </a>| <a href="http://y77778.com" target="_blank">美女尤物久久精品</a>| <a href="http://1515t.com" target="_blank">亚洲国产精彩中文乱码av在线播放 </a>| <a href="http://www-4157.com" target="_blank">国内精品一区二区三区</a>| <a href="http://444al.com" target="_blank">亚洲黄色在线</a>| <a href="http://300618.com" target="_blank">亚洲欧美视频在线观看</a>| <a href="http://778hao.com" target="_blank">久久久久久69</a>| <a href="http://qvod777.com" target="_blank">日韩午夜高潮</a>| <a href="http://h15h15.com" target="_blank">久久精品视频在线免费观看</a>| <a href="http://xigou666.com" target="_blank">欧美肥婆bbw</a>| <a href="http://caox8.com" target="_blank">国产亚洲欧美一区二区</a>| <a href="http://www520590.com" target="_blank">亚洲人午夜精品免费</a>| <a href="http://lutube666.com" target="_blank">欧美一区二区三区在</a>| <a href="http://17oooo.com" target="_blank">亚洲国产99</a>| <a href="http://www9ckk1.com" target="_blank">欧美亚洲尤物久久</a>| <a href="http://konwoosh.com" target="_blank">欧美激情一区三区</a>| <a href="http://cz-hongbangfloor.com" target="_blank">国产偷国产偷精品高清尤物</a>| <a href="http://shnenglu.com" target="_blank">99视频有精品</a>| <a href="http://liuyangzi.com" target="_blank">久久一区二区精品</a>| <a href="http://928uc.com" target="_blank">亚洲一区二区免费视频</a>| <a href="http://4923cc.com" target="_blank">欧美成人精品1314www</a>| <a href="http://26163c.com" target="_blank">国产亚洲视频在线观看</a>| <a href="http://ez4444.com" target="_blank">亚洲小视频在线</a>| <a href="http://cqrebo.com" target="_blank">亚洲国产裸拍裸体视频在线观看乱了中文</a>| <a href="http://51jieyanla.com" target="_blank">宅男噜噜噜66国产日韩在线观看</a>| <a href="http://liuyangzi.com" target="_blank">久久久av网站</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>