锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产欧美 在线欧美,欧美一区二区三区在线,韩曰欧美视频免费观看http://www.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://www.shnenglu.com/huangyi5209/articles/144084.htmlhuangyi5209huangyi5209Tue, 12 Apr 2011 23:13:00 GMThttp://www.shnenglu.com/huangyi5209/articles/144084.htmlhttp://www.shnenglu.com/huangyi5209/comments/144084.htmlhttp://www.shnenglu.com/huangyi5209/articles/144084.html#Feedback0http://www.shnenglu.com/huangyi5209/comments/commentRss/144084.htmlhttp://www.shnenglu.com/huangyi5209/services/trackbacks/144084.html闃呰鍏ㄦ枃

]]>
InterlockedExchange 綰跨▼鍚屾http://www.shnenglu.com/huangyi5209/articles/142860.htmlhuangyi5209huangyi5209Mon, 28 Mar 2011 08:09:00 GMThttp://www.shnenglu.com/huangyi5209/articles/142860.htmlhttp://www.shnenglu.com/huangyi5209/comments/142860.htmlhttp://www.shnenglu.com/huangyi5209/articles/142860.html#Feedback0http://www.shnenglu.com/huangyi5209/comments/commentRss/142860.htmlhttp://www.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://www.shnenglu.com/huangyi5209/articles/141190.htmlhuangyi5209huangyi5209Sun, 06 Mar 2011 01:26:00 GMThttp://www.shnenglu.com/huangyi5209/articles/141190.htmlhttp://www.shnenglu.com/huangyi5209/comments/141190.htmlhttp://www.shnenglu.com/huangyi5209/articles/141190.html#Feedback0http://www.shnenglu.com/huangyi5209/comments/commentRss/141190.htmlhttp://www.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://www.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://www.shnenglu.com/huangyi5209/articles/141142.html</guid><wfw:comment>http://www.shnenglu.com/huangyi5209/comments/141142.html</wfw:comment><comments>http://www.shnenglu.com/huangyi5209/articles/141142.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/huangyi5209/comments/commentRss/141142.html</wfw:commentRss><trackback:ping>http://www.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://www.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://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/None.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_102_452_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_298_377_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        WaitForSingleObject(hEvent, INFINITE);<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://www.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://www.shnenglu.com/Images/dot.gif"><img src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_465_1219_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.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://www.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://www.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://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    DWORD Id;<br><img align=top src="http://www.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://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_773_813_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         CloseHandle(hThrd);<br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.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://www.shnenglu.com/Images/dot.gif">.</span><span style="COLOR: #008000"><br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_922_1035_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        SetEvent(hEvent);<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    WaitForSingleObject(hThrd, INFINITE);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hThrd);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    <br><img align=top src="http://www.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://www.shnenglu.com/Images/dot.gif"><img src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_18_465_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_214_390_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">        WaitForSingleObject(hEvent, INFINITE);<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        ResetEvent(hEvent);<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://www.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://www.shnenglu.com/Images/dot.gif"><img src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_478_1221_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.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://www.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://www.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://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    DWORD Id;<br><img align=top src="http://www.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://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_775_815_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">         CloseHandle(hThrd);<br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.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://www.shnenglu.com/Images/dot.gif">.</span><span style="COLOR: #008000"><br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.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://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_924_1037_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">        SetEvent(hEvent);<br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">    }</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"></span><span style="COLOR: #000000">    WaitForSingleObject(hThrd, INFINITE);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hThrd);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    CloseHandle(hEvent);<br><img align=top src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif">    <br><img align=top src="http://www.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://www.shnenglu.com/Images/dot.gif"><img src="http://www.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://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif"><br><img align=top src="http://www.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://www.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://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span></div> <img src ="http://www.shnenglu.com/huangyi5209/aggbug/141142.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huangyi5209/" target="_blank">huangyi5209</a> 2011-03-05 08:30 <a href="http://www.shnenglu.com/huangyi5209/articles/141142.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>ASCII 杞?UNICODEhttp://www.shnenglu.com/huangyi5209/articles/141141.htmlhuangyi5209huangyi5209Fri, 04 Mar 2011 23:57:00 GMThttp://www.shnenglu.com/huangyi5209/articles/141141.htmlhttp://www.shnenglu.com/huangyi5209/comments/141141.htmlhttp://www.shnenglu.com/huangyi5209/articles/141141.html#Feedback0http://www.shnenglu.com/huangyi5209/comments/commentRss/141141.htmlhttp://www.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://www.shnenglu.com/huangyi5209/articles/139240.htmlhuangyi5209huangyi5209Mon, 24 Jan 2011 12:29:00 GMThttp://www.shnenglu.com/huangyi5209/articles/139240.htmlhttp://www.shnenglu.com/huangyi5209/comments/139240.htmlhttp://www.shnenglu.com/huangyi5209/articles/139240.html#Feedback0http://www.shnenglu.com/huangyi5209/comments/commentRss/139240.htmlhttp://www.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://www.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://www.shnenglu.com/huangyi5209/articles/139239.html</guid><wfw:comment>http://www.shnenglu.com/huangyi5209/comments/139239.html</wfw:comment><comments>http://www.shnenglu.com/huangyi5209/articles/139239.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/huangyi5209/comments/commentRss/139239.html</wfw:commentRss><trackback:ping>http://www.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://www.shnenglu.com/huangyi5209/aggbug/139239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/huangyi5209/" target="_blank">huangyi5209</a> 2011-01-24 20:26 <a href="http://www.shnenglu.com/huangyi5209/articles/139239.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <a href="http://www.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://northboiler.com" target="_blank">亚洲黄色在线视频</a>| <a href="http://hcbr365.com" target="_blank">欧美 日韩 国产 一区</a>| <a href="http://cao3e8c8.com" target="_blank">欧美午夜精品一区</a>| <a href="http://36seaa.com" target="_blank">亚洲免费福利视频</a>| <a href="http://filark.com" target="_blank">99精品国产在热久久</a>| <a href="http://cp50088.com" target="_blank">美女免费视频一区</a>| <a href="http://www-74987.com" target="_blank">亚洲国产成人精品久久</a>| <a href="http://88844401.com" target="_blank">亚洲国语精品自产拍在线观看</a>| <a href="http://845821.com" target="_blank">亚洲欧美国产高清</a>| <a href="http://duoying668.com" target="_blank">久久久国产精品一区</a>| <a href="http://94wr.com" target="_blank">红杏aⅴ成人免费视频</a>| <a href="http://qcjpns.com" target="_blank">久久亚洲春色中文字幕</a>| <a href="http://trhht.com" target="_blank">亚洲国产毛片完整版</a>| <a href="http://fyfsds.com" target="_blank">亚洲一级二级</a>| <a href="http://yy6024.com" target="_blank">国产欧美日韩在线播放</a>| <a href="http://551731.com" target="_blank">久久久久www</a>| <a href="http://gzpurefaith.com" target="_blank">久久久久久久网站</a>| <a href="http://guanghezixun.com" target="_blank">亚洲高清视频一区二区</a>| <a href="http://ebmsci.com" target="_blank">欧美精品一区二区精品网</a>| <a href="http://7467tom.com" target="_blank">欧美不卡在线</a>| <a href="http://807225.com" target="_blank">99在线热播精品免费</a>| <a href="http://687989.com" target="_blank">国产精品美女午夜av</a>| <a href="http://227c7.com" target="_blank">久久精品亚洲一区二区</a>| <a href="http://cabenn.com" target="_blank">欧美激情91</a>| <a href="http://oo853kj.com" target="_blank">亚洲在线一区</a>| <a href="http://987gqb.com" target="_blank">激情综合久久</a>| <a href="http://yichenep.com" target="_blank">欧美aⅴ一区二区三区视频</a>| <a href="http://sdsankeguo.com" target="_blank">日韩亚洲精品视频</a>| <a href="http://994745.com" target="_blank">久久久国产精品一区二区三区</a>| <a href="http://nxhjzddata.com" target="_blank">在线日本成人</a>| <a href="http://www-n77.com" target="_blank">国产精品r级在线</a>| <a href="http://www672hh.com" target="_blank">久久久久99</a>| <a href="http://7770790.com" target="_blank">99国产精品久久久久久久</a>| <a href="http://vvv3939.com" target="_blank">久久激情网站</a>| <a href="http://jiuzuifusheng.com" target="_blank">亚洲免费福利视频</a>| <a href="http://roujizz.com" target="_blank">国产亚洲欧洲</a>| <a href="http://3b6f.com" target="_blank">欧美日韩精品免费观看视频完整</a>| <a href="http://fobdoer.com" target="_blank">亚洲一区二区欧美</a>| <a href="http://645955.com" target="_blank">久久久久久久999精品视频</a>| <a href="http://y4088.com" target="_blank">亚洲人成在线观看网站高清</a>| <a href="http://www205sihu.com" target="_blank">国产精品视频专区</a>| <a href="http://gaobb52.com" target="_blank">久久亚洲一区二区</a>| <a href="http://www515678.com" target="_blank">在线亚洲欧美</a>| <a href="http://www668889.com" target="_blank">欧美激情视频一区二区三区免费</a>| <a href="http://126900.com" target="_blank">亚洲香蕉在线观看</a>| <a href="http://5s5s5s.com" target="_blank">亚洲第一中文字幕在线观看</a>| <a href="http://559dd.com" target="_blank">欧美网站在线观看</a>| <a href="http://www4455va.com" target="_blank">麻豆91精品</a>| <a href="http://shanghaijiagu.com" target="_blank">欧美亚洲综合网</a>| <a href="http://830085.com" target="_blank">99精品国产热久久91蜜凸</a>| <a href="http://luoliguo.com" target="_blank">麻豆精品视频在线</a>| <a href="http://shght.com" target="_blank">欧美一区二区三区在线</a>| <a href="http://929889.com" target="_blank">亚洲精品中文字幕在线观看</a>| <a href="http://yanuoxun.com" target="_blank">在线日本成人</a>| <a href="http://621768.com" target="_blank">在线观看日韩av电影</a>| <a href="http://dxmdzz.com" target="_blank">好看不卡的中文字幕</a>| <a href="http://derinsolar.com" target="_blank">国产人久久人人人人爽</a>| <a href="http://szxrdr.com" target="_blank">国产精品美女在线观看</a>| <a href="http://xxxbobba.com" target="_blank">国产精品yjizz</a>| <a href="http://cqjk120.com" target="_blank">欧美日韩一区在线播放</a>| <a href="http://060969.com" target="_blank">欧美日韩亚洲一区二区三区在线观看</a>| <a href="http://fobdoer.com" target="_blank">欧美二区不卡</a>| <a href="http://naturalgiftfashion.com" target="_blank">欧美大秀在线观看</a>| <a href="http://7770790.com" target="_blank">欧美激情一区</a>| <a href="http://域名" target="_blank">欧美日韩综合视频</a>| <a href="http://569658.com" target="_blank">国产精品扒开腿做爽爽爽软件 </a>| <a href="http://91see8.com" target="_blank">国产亚洲欧洲</a>| <a href="http://www38044.com" target="_blank">国产手机视频精品</a>| <a href="http://sesese98.com" target="_blank">国产婷婷色一区二区三区在线</a>| <a href="http://603445.com" target="_blank">国产精品午夜在线观看</a>| <a href="http://www5566szy.com" target="_blank">国产欧美日韩精品丝袜高跟鞋</a>| <a href="http://qscxx3.com" target="_blank">国产女精品视频网站免费</a>| <a href="http://wwwnnnn.com" target="_blank">国产日韩精品一区二区三区在线</a>| <a href="http://110673.com" target="_blank">国产精品综合</a>| <a href="http://sese912.com" target="_blank">一区二区三区在线视频观看</a>| <a href="http://birhit.com" target="_blank">尤物精品在线</a>| <a href="http://72nnnn.com" target="_blank">亚洲精品乱码久久久久久蜜桃麻豆</a>| <a href="http://cz-sensor.com" target="_blank">亚洲精品乱码久久久久久日本蜜臀</a>| <a href="http://v63xs.com" target="_blank">亚洲日本中文</a>| <a href="http://czjrby.com" target="_blank">亚洲一区二区伦理</a>| <a href="http://nxyhbz.com" target="_blank">欧美一区二区观看视频</a>| <a href="http://jiangnanmm.com" target="_blank">久久黄色影院</a>| <a href="http://961318.com" target="_blank">欧美国产日韩一区二区在线观看</a>| <a href="http://www23sds.com" target="_blank">欧美激情视频在线播放</a>| <a href="http://y1bbs.com" target="_blank">日韩午夜精品</a>| <a href="http://ju255.com" target="_blank">午夜免费在线观看精品视频</a>| <a href="http://nnnn34.com" target="_blank">久久成人综合网</a>| <a href="http://405151.com" target="_blank">久久中文精品</a>| <a href="http://www33444.com" target="_blank">欧美日韩一区二区免费在线观看</a>| <a href="http://977dy.com" target="_blank">国产精品九九久久久久久久</a>| <a href="http://www-xj788.com" target="_blank">国产亚洲精品久久飘花</a>| <a href="http://fuwu56.com" target="_blank">亚洲国产高清在线观看视频</a>| <a href="http://www94816.com" target="_blank">99成人在线</a>| <a href="http://tuokuba520.com" target="_blank">欧美一区深夜视频</a>| <a href="http://cm1-100.com" target="_blank">欧美国产第一页</a>| <a href="http://sikixixw12.com" target="_blank">99精品视频免费观看视频</a>| <a href="http://414670.com" target="_blank">香蕉久久夜色</a>| <a href="http://69kun.com" target="_blank">欧美黑人国产人伦爽爽爽</a>| <a href="http://1181318.com" target="_blank">国产精品久久久久久久久久直播 </a>| <a href="http://aaddgg66.com" target="_blank">亚洲成色999久久网站</a>| <a href="http://3534m.com" target="_blank">日韩视频在线观看</a>| <a href="http://quoviajes.com" target="_blank">欧美一级在线亚洲天堂</a>| <a href="http://pabjzz.com" target="_blank">免费欧美网站</a>| <a href="http://av0333.com" target="_blank">一区二区三区欧美</a>| <a href="http://shwazrbjd.com" target="_blank">久久久精品国产免费观看同学</a>| <a href="http://wwwmm131.com" target="_blank">欧美1区2区</a>| <a href="http://wg246.com" target="_blank">国产女同一区二区</a>| <a href="http://3dmh329.com" target="_blank">亚洲日本黄色</a>| <a href="http://nxhjzddata.com" target="_blank">久久精品国产99精品国产亚洲性色 </a>| <a href="http://6688se.com" target="_blank">欧美日韩一区二区三区</a>| <a href="http://www25sds.com" target="_blank">国产一区二区三区免费在线观看</a>| <a href="http://261262.com" target="_blank">亚洲精品国产精品乱码不99 </a>| <a href="http://330310c.com" target="_blank">在线看片一区</a>| <a href="http://yichenep.com" target="_blank">亚洲欧美激情一区</a>| <a href="http://www515678.com" target="_blank">欧美国产成人在线</a>| <a href="http://xxdd19.com" target="_blank">亚洲欧美一区二区三区在线</a>| <a href="http://wanyoulipin.com" target="_blank">免费欧美日韩国产三级电影</a>| <a href="http://wwwmm7777.com" target="_blank">国产精品一区二区在线</a>| <a href="http://playav999.com" target="_blank">亚洲精品免费一二三区</a>| <a href="http://83mmmm.com" target="_blank">久久精品国产亚洲精品</a>| <a href="http://spidermanseo.com" target="_blank">亚洲精品色婷婷福利天堂</a>| <a href="http://88488848.com" target="_blank">久久精品视频在线看</a>| <a href="http://49vvvv.com" target="_blank">国产精品theporn88</a>| <a href="http://lexueit.com" target="_blank">亚洲精品久久视频</a>| <a href="http://hoppecoke.com" target="_blank">久久青草福利网站</a>| <a href="http://gaobb52.com" target="_blank">亚洲小少妇裸体bbw</a>| <a href="http://csmgxun.com" target="_blank">欧美国产日产韩国视频</a>| <a href="http://5588207.com" target="_blank">精品51国产黑色丝袜高跟鞋</a>| <a href="http://7c3e.com" target="_blank">欧美亚洲日本国产</a>| <a href="http://a718sx.com" target="_blank">亚洲麻豆视频</a>| <a href="http://8004006.com" target="_blank">欧美成人dvd在线视频</a>| <a href="http://566805.com" target="_blank">国产综合色精品一区二区三区</a>| <a href="http://zuan3344.com" target="_blank">亚洲中字在线</a>| <a href="http://d77dd.com" target="_blank">亚洲精品免费在线</a>| <a href="http://lyminghang.com" target="_blank">久久综合99re88久久爱</a>| <a href="http://aa224.com" target="_blank">韩国一区二区三区美女美女秀</a>| <a href="http://378682.com" target="_blank">亚洲一区国产</a>| <a href="http://wawabt.com" target="_blank">日韩亚洲成人av在线</a>| <a href="http://fjccjq.com" target="_blank">欧美高清在线</a>| <a href="http://nmbgbc.com" target="_blank">亚洲激情视频在线播放</a>| <a href="http://www-787788.com" target="_blank">美女国产精品</a>| <a href="http://246767.com" target="_blank">久久久久一区二区</a>| <a href="http://082235.com" target="_blank">国产一区在线看</a>| <a href="http://136066.com" target="_blank">久久国产精品黑丝</a>| <a href="http://scratbag.com" target="_blank">亚洲天堂成人</a>| <a href="http://xxxyyy168.com" target="_blank">国产精品白丝av嫩草影院</a>| <a href="http://woaigougou.com" target="_blank">99这里有精品</a>| <a href="http://7269003.com" target="_blank">亚洲精品国产拍免费91在线</a>| <a href="http://7628x.com" target="_blank">免费欧美电影</a>| <a href="http://789583.com" target="_blank">最新国产精品拍自在线播放</a>| <a href="http://9955377.com" target="_blank">久久久蜜桃一区二区人</a>| <a href="http://378682.com" target="_blank">欧美永久精品</a>| <a href="http://9876666.com" target="_blank">国产永久精品大片wwwapp</a>| <a href="http://737sihu.com" target="_blank">久久激情视频</a>| <a href="http://32m8.com" target="_blank">久久se精品一区精品二区</a>| <a href="http://dy123456.com" target="_blank">国产亚洲精品v</a>| <a href="http://97seee.com" target="_blank">久久久久久亚洲综合影院红桃</a>| <a href="http://97sgg.com" target="_blank">午夜精品免费在线</a>| <a href="http://szxrdr.com" target="_blank">国产一区二区三区精品欧美日韩一区二区三区</a>| <a href="http://qscxx3.com" target="_blank">亚洲欧美美女</a>| <a href="http://by2866.com" target="_blank">香蕉久久夜色精品</a>| <a href="http://9xxpp.com" target="_blank">国内精品视频666</a>| <a href="http://caoav8.com" target="_blank">牛牛影视久久网</a>| <a href="http://785448.com" target="_blank">欧美大片免费观看</a>| <a href="http://ccnn33.com" target="_blank">在线一区二区三区四区五区</a>| <a href="http://www-68689.com" target="_blank">日韩一级精品视频在线观看</a>| <a href="http://sdjzzs.com" target="_blank">欧美色图天堂网</a>| <a href="http://kaijiepharm.com" target="_blank">午夜电影亚洲</a>| <a href="http://ywbst8g4tukcsqhioikc.com" target="_blank">亚洲欧美中文另类</a>| <a href="http://668www.com" target="_blank">国内精品国语自产拍在线观看</a>| <a href="http://389746.com" target="_blank">久久手机免费观看</a>| <a href="http://xdlot.com" target="_blank">蜜桃av久久久亚洲精品</a>| <a href="http://430390.com" target="_blank">日韩一级黄色大片</a>| <a href="http://aijiashe.com" target="_blank">99视频在线精品国自产拍免费观看</a>| <a href="http://04781900.com" target="_blank">欧美手机在线视频</a>| <a href="http://xshgwy.com" target="_blank">欧美在线日韩在线</a>| <a href="http://8181777.com" target="_blank">久久久蜜桃精品</a>| <a href="http://wwwxigua66.com" target="_blank">亚洲免费av片</a>| <a href="http://samucorvin.com" target="_blank">亚洲一区二区在线视频</a>| <a href="http://www524141.com" target="_blank">国产毛片久久</a>| <a href="http://www381818.com" target="_blank">欧美本精品男人aⅴ天堂</a>| <a href="http://yidaiban.com" target="_blank">欧美激情综合五月色丁香</a>| <a href="http://b1768.com" target="_blank">亚洲尤物视频在线</a>| <a href="http://www-yh6.com" target="_blank">欧美一级艳片视频免费观看</a>| <a href="http://luoliguo.com" target="_blank">在线观看欧美日韩</a>| <a href="http://yw3328.com" target="_blank">日韩视频中文字幕</a>| <a href="http://3314133.com" target="_blank">国产毛片一区</a>| <a href="http://0070571.com" target="_blank">欧美激情一区二区三区在线视频观看 </a>| <a href="http://alio-ai.com" target="_blank">性久久久久久久久久久久</a>| <a href="http://www-33tt.com" target="_blank">久久av最新网址</a>| <a href="http://329374.com" target="_blank">99热在这里有精品免费</a>| <a href="http://saobitv.com" target="_blank">亚洲女与黑人做爰</a>| <a href="http://3848404.com" target="_blank">亚洲国内在线</a>| <a href="http://5a07.com" target="_blank">亚洲欧美欧美一区二区三区</a>| <a href="http://cnm24.com" target="_blank">在线免费精品视频</a>| <a href="http://566805.com" target="_blank">亚洲无玛一区</a>| <a href="http://avse69.com" target="_blank">91久久中文</a>| <a href="http://kdy444.com" target="_blank">亚洲欧美伊人</a>| <a href="http://www-tk3333.com" target="_blank">日韩视频在线观看</a>| <a href="http://cm168168.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>