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

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

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

using namespace std;

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


void Func1() 


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

    ENTER_LFS_LOCK_;

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

    EXIT_LFS_LOCK_;

}
 



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

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

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


    system(
"pause");
    
return 0;
}


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

using namespace std;

static int g_n;
CRITICAL_SECTION m_cs;

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

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

    LeaveCriticalSection(
&m_cs);
    
return 0;
}


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

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

    LeaveCriticalSection(
&m_cs);
    
return 0;
}


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

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

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

    system(
"pause");
    
return 0;
}

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

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

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

CWinApp theApp;

using namespace std;

CCriticalSection c_s;
static int g_C;

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

    
lock.Lock();

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

    
lock.Unlock();
    
return 0;
}


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

    
lock.Lock();

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

    
lock.Unlock();
    
return 0;
}


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

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

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

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

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

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


    system(
"pause");
    
return nRetCode;
}




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

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


     
return result;
}


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

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


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

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

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

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

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

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

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

Pointers are subject to no such restriction:

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

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

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

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

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

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

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

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

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



]]>
Callback Functions Tutorial - C++鐨勫洖璋冨嚱鏁版満鍒?/title><link>http://m.shnenglu.com/huangyi5209/articles/139239.html</link><dc:creator>huangyi5209</dc:creator><author>huangyi5209</author><pubDate>Mon, 24 Jan 2011 12:26:00 GMT</pubDate><guid>http://m.shnenglu.com/huangyi5209/articles/139239.html</guid><wfw:comment>http://m.shnenglu.com/huangyi5209/comments/139239.html</wfw:comment><comments>http://m.shnenglu.com/huangyi5209/articles/139239.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/huangyi5209/comments/commentRss/139239.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/huangyi5209/services/trackbacks/139239.html</trackback:ping><description><![CDATA[<div class="hvzpftn" id="display_content" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; "><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Introduction</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If you are reading this article, you probably wonder what callback functions are. This article explains what callback functions are, what are they good for, why you should use them, and so forth. However, before learning what callback functions are, you must be familiar with function pointers. If you aren't, consult a C/C++ book or consider reading the following:</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">The Syntax of C and C++ Function Pointers</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Pointers to member functions</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Declaring, Assigning, and Using Function Pointers</a></li></ul><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">What Is a Callback Function?</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">The simple answer to this first question is that a callback function is a function that is called through a function pointer. If you pass the pointer (address) of a function as an argument to another, when that pointer is used to call the function it points to it is said that a call back is made.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Why Should You Use Callback Functions?</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Because they uncouple the caller from the callee. The caller doesn't care who the callee is; all it knows is that there is a callee with a certain prototype and probably some restriction (for instance, the returned value can be int, but certain values have certain meanings).</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If you are wondering how is that useful in practice, imagine that you want to write a library that provides implementation for sorting algorithms (yes, that is pretty classic), such as bubble sort, shell short, shake sort, quick sort, and others. The catch is that you don't want to embed the sorting logic (which of two elements goes first in an array) into your functions, making your library more general to use. You want the client to be responsible to that kind of logic. Or, you want it to be used for various data types (ints, floats, strings, and so on). So, how do you do it? You use function pointers and make callbacks.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">A callback can be used for notifications. For instance, you need to set a timer in your application. Each time the timer expires, your application must be notified. But, the implementer of the time'rs mechanism doesn't know anything about your application. It only wants a pointer to a function with a given prototype, and in using that pointer it makes a callback, notifying your application about the event that has occurred. Indeed, the SetTimer() WinAPI uses a callback function to notify that the timer has expired (and, in case there is no callback function provided, it posts a message to the application's queue).</p><div id="hvzpftn" class="toolbox noBullets colRight" style="margin-top: 15px; margin-right: 0px; margin-bottom: 5px; margin-left: 10px; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; float: right; width: 160px; border-left-color: rgb(204, 204, 204); font-size: 11px; clear: both; "><ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 5px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 5px; "><li id="hvzpftn" class="comment_linky" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 25px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/icon_comment.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 50%; background-repeat: no-repeat no-repeat; "><a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; "><nobr>Post a comment</nobr></a></li><li id="hvzpftn" class="email" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 25px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/icon_email.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 50%; background-repeat: no-repeat no-repeat; "><a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; ">Email Article</a></li><li id="hvzpftn" class="print" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 25px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/icon_print.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; background-position: 0% 50%; background-repeat: no-repeat no-repeat; "><a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; ">Print Article</a></li><li id="toolBoxShareMenu" class="share" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: -12px; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 12px; list-style-type: none; list-style-position: outside; list-style-image: initial; background-image: url(http://www.codeguru.com/newimg/images/share_article-bg.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; z-index: 100; position: relative; background-position: 0px -1000px; background-repeat: no-repeat no-repeat; "><img height="16" width="16" class="icon" alt="" src="http://www.codeguru.com/newimg/images/icon_share.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: middle; margin-top: 0px; margin-right: 5px; margin-bottom: 2px; margin-left: 0px; "> <a rel="nofollow" style="color: rgb(5, 48, 97); text-decoration: underline !important; font-weight: bold; ">Share Articles</a><img src="http://www.codeguru.com/newimg/images/arrow_down_spblue.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: middle; margin-top: 0px; margin-right: 5px; margin-bottom: 2px; margin-left: 0px; "></li></ul></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Another example from WinAPI functions that use callback mechanism is EnumWindow(), which enumerates all the top-level windows on the screen. EnumWindow() iterates over the top-level windows, calling an application-provided function for each window, passing the handler of the window. If the callee returns a value, the iteration continues; otherwise, it stops. EnumWindows() just doesn't care where the callee is and what it does with the handler it passes over. It is only interested in the return value, because based on that it continues its execution or not.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">However, callback functions are inherited from C. Thus, in C++, they should be only used for interfacing C code and existing callback interfaces. Except for these situations, you should use virtual methods or functors, not callback functions.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">A Simple Implementation Example</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Now, follow the example that can be found in the attached files. I have created a dynamic linked library called sort.dll. It exports a type called CompareFunction:</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">typedef int (__stdcall *CompareFunction)(const byte*, const byte*);</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">which will be the type of your callback functions. It also exports two methods, called Bubblesort() and Quicksort(), which have the same prototype but provide different behavior by implementing the sorting algorithms with the same name.</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">void DLLDIR __stdcall Bubblesort(byte* array, int size, int elem_size, CompareFunction cmpFunc); void DLLDIR __stdcall Quicksort(byte* array, int size, int elem_size, CompareFunction cmpFunc); </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">These two functions take the following parameters:</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>byte* array</em>: a pointer to an array of elements (doesn't matter of which type)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>int size</em>: the number of elements in the array</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>int elem_size</em>: the size, in bytes, of an element of the array</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><em>CompareFunction cmpFunc</em>: a pointer to a callback function with the prototype listed above</li></ul><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">The implementation of these two functions performs a sorting of the array. But, each time there is a need to decide which of two elements goes first, a callback is made to the function whose address was passed as an argument. For the library writer, it doesn't matter where that function is implemented, or how it is implemented. All that matters it is that it takes the address of two elements (that are the two be compared) and it returns one of the following values (this is a contract between the library developers and its clients):</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; ">-1: if the first element is lesser and/or should go before the second element (in a sorted array)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; ">0: if the two elements are equal and/or their relative position doesn't matter (each one can go before the other in a sorted array)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; ">1: if the first element is greater and/or should go after the second element (in a sorted array)</li></ul><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">With this contract explicitly stated, the implementation of the Bubblesort() function is this (for Quicksort(), which a little bit more complicated, see the attached files).</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">void DLLDIR __stdcall Bubblesort(byte* array, int size, int elem_size, CompareFunction cmpFunc) { for(int i=0; i < size; i++) { for(int j=0; j < size-1; j++) { // make the callback to the comparison function if(1 == (*cmpFunc)(array+j*elem_size, array+(j+1)*elem_size)) { // the two compared elements must be interchanged byte* temp = new byte[elem_size]; memcpy(temp, array+j*elem_size, elem_size); memcpy(array+j*elem_size, array+(j+1)*elem_size, elem_size); memcpy(array+(j+1)*elem_size, temp, elem_size); delete [] temp; } } } } </pre><blockquote style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 1em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong>Note</strong>: Because the implementation uses memcpy(), these library functions should not be used for types other than POD (Plain-Old-Data).</blockquote><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">On the client side, there must be a callback function whose address is to be passed to the Bubblesort() function. As a simple example, I have written a function that compares two integer values and one that compares two strings:</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">int __stdcall CompareInts(const byte* velem1, const byte* velem2) { int elem1 = *(int*)velem1; int elem2 = *(int*)velem2; if(elem1 < elem2) return -1; if(elem1 > elem2) return 1; return 0; } int __stdcall CompareStrings(const byte* velem1, const byte* velem2) { const char* elem1 = (char*)velem1; const char* elem2 = (char*)velem2; return strcmp(elem1, elem2); } </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">To put all these to a test, I have written this short program. It passes an array with five elements to Bubblesort() or Quicksort() along with the pointer to the callback functions.</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">int main(int argc, char* argv[]) { int i; int array[] = {5432, 4321, 3210, 2109, 1098}; cout << "Before sorting ints with Bubblesort\n"; for(i=0; i < 5; i++) cout << array[i] << '\n'; Bubblesort((byte*)array, 5, sizeof(array[0]), &CompareInts); cout << "After the sorting\n"; for(i=0; i < 5; i++) cout << array[i] << '\n'; const char str[5][10] = {"estella", "danielle", "crissy", "bo", "angie"}; cout << "Before sorting strings with Quicksort\n"; for(i=0; i < 5; i++) cout << str[i] << '\n'; Quicksort((byte*)str, 5, 10, &CompareStrings); cout << "After the sorting\n"; for(i=0; i < 5; i++) cout << str[i] << '\n'; return 0; } </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If I decide that I want the sorting to be done descending (with the biggest element first), all I have to do is to change the callback function code, or provide another that implements the desired logic.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Calling Conventions</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">In the above code, you can see the word <em>__stdcall</em> in the function's prototype. Because it starts with a double underscore, it is, of course, a compiler-specific extension, more exactly a Microsoft-specific one. Any compiler that supports development of Win32-based applications must support this or an equivalent one. A function that is marked with <em>__stdcall</em> uses the standard calling convention so named because all Win32 API functions (except the few that take variable arguments) use it. Functions that follow the standard calling convention remove the parameters from the stack before they return to the caller. This is the standard convention for Pascal. But in C/C++, the calling convention is that the caller cleans up the stack instead of the called function. To enforce that a function uses the C/C++ calling convention, <em>__cdecl</em>must be used. Variable argument functions use the C/C++ calling convention.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Windows adopted the standard calling convention (Pascal convention) because it reduces the size of the code. This was very important in the early days of Windows, when it ran on systems with 640 KB RAM.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">If you don't like the word <em>__stdcall</em>, you can use the <strong>CALLBACK</strong> macro, defined in windef.h, as</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">#define CALLBACK __stdcall</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">or</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">#define CALLBACK PASCAL</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">where PASCAL is #defined as __stdcall.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">You can read more about calling convention here: <a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Calling Convetions in Microsoft Visual C++</a>.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">C++ Methods as Callback Functions</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">Because you probably write in C++, you want your callback function a method of a class. But, if you try this:</p><pre style="margin-top: 3px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-family: 'courier new', monospace; background-image: url(http://www.codeguru.com/newimg/images/paperbg.gif); background-attachment: scroll; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 2px; border-right-width: 2px; border-bottom-width: 2px; border-left-width: 2px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(245, 243, 215); border-right-color: rgb(245, 243, 215); border-bottom-color: rgb(245, 243, 215); border-left-color: rgb(245, 243, 215); color: rgb(0, 0, 0); width: 570px; display: block; font-size: 13px; line-height: 16px; overflow-x: auto; min-height: 30px; background-position: 0px 0px; background-repeat: repeat repeat; ">class CCallbackTester { public: int CALLBACK CompareInts(const byte* velem1, const byte* velem2); }; Bubblesort((byte*)array, 5, sizeof(array[0]), &CCallbackTester::CompareInts); </pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">with a MS compiler, you get this compilation error:</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; "><em>error C2664: 'Bubblesort' : cannot convert parameter 4 from 'int (__stdcall CCallbackTester::*)(const unsigned char *,const unsigned char *)' to 'int (__stdcall *)(const unsigned char *,const unsigned char *)' There is no context in which this conversion is possible</em></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">That happens because non-static member functions have an additional parameter, pointer <em>this</em> (see this<a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">FAQ</a> for more).</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">That obliges you to make the member function static. If that's not acceptable, you can use several techniques to overcome that. Check the following links to learn more.</p><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">How to Implement Callbacks in C and C++</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">C++ Callback Demo</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Callbacks in C++ Using Template Functors</a></li></ul><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Notices</h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; ">The attached files contain two projects. <em>SortingDLL</em> is a Win32 DLL project. The sort.dll output library exports the two sorting functions, Bubblesort() and Quicksort(). The second project, <em>SortDemo</em>, is a Win32 Console Application that demonstrates how to use the sort.dll library. The output directory for both projects is <em>Shared</em> directory, where the following files can be found: sort.h, sort.dll, sort.lib, and SortDemo.exe.</p><h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 13px; font-weight: bold; color: rgb(0, 0, 63); ">Further References</h3><ul style="margin-top: 1em; margin-right: 1em; margin-bottom: 1em; margin-left: 2em; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">C++ OO Callback Technique</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Function Pointers to Non-Static Object Methods</a></li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: disc; list-style-position: outside; list-style-image: initial; "><a target="new" style="color: rgb(5, 48, 97); text-decoration: underline !important; ">Pointers and References</a></li></ul></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; font-weight: bold; color: rgb(0, 0, 63); line-height: 1.5em; font-family: Arial, Helvetica, sans-serif; ">About the Author</h2><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; ">Marius Bancila is a Microsoft MVP for VC++. He works as a software developer for a Norwegian-based company. He is mainly focused on building desktop applications with MFC and VC#. He keeps a blog at www.mariusbancila.ro/blog, focused on Windows programming. He is the co-founder of codexpert.ro, a community for Romanian C++/VC++ programmers.<br style="font-size: 12px; line-height: 1em; "><br style="font-size: 12px; line-height: 1em; "></div><h2 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; font-weight: bold; color: rgb(0, 0, 63); line-height: 1.5em; font-family: Arial, Helvetica, sans-serif; ">Downloads</h2><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 18px; "><a style="color: rgb(5, 48, 97); text-decoration: underline !important; ">callbacks.zip</a></li> <img src ="http://m.shnenglu.com/huangyi5209/aggbug/139239.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/huangyi5209/" target="_blank">huangyi5209</a> 2011-01-24 20:26 <a href="http://m.shnenglu.com/huangyi5209/articles/139239.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <a href="http://m.shnenglu.com/">青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品</a> <div style="position:fixed;left:-9000px;top:-9000px;"><font id="pjuwb"></font><button id="pjuwb"><pre id="pjuwb"></pre></button><sub id="pjuwb"></sub><tbody id="pjuwb"><var id="pjuwb"><address id="pjuwb"></address></var></tbody><listing id="pjuwb"><label id="pjuwb"><strong id="pjuwb"></strong></label></listing><wbr id="pjuwb"><small id="pjuwb"><tbody id="pjuwb"></tbody></small></wbr><ins id="pjuwb"><xmp id="pjuwb"></xmp></ins><style id="pjuwb"></style><label id="pjuwb"><em id="pjuwb"><li id="pjuwb"></li></em></label><samp id="pjuwb"></samp><menu id="pjuwb"><input id="pjuwb"></input></menu><pre id="pjuwb"><tbody id="pjuwb"><tfoot id="pjuwb"><button id="pjuwb"></button></tfoot></tbody></pre><form id="pjuwb"></form><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"><sup id="pjuwb"></sup></label></style></i><li id="pjuwb"><table id="pjuwb"><abbr id="pjuwb"></abbr></table></li><video id="pjuwb"></video><dfn id="pjuwb"></dfn><progress id="pjuwb"></progress><strong id="pjuwb"></strong><mark id="pjuwb"></mark><em id="pjuwb"></em><tbody id="pjuwb"><p id="pjuwb"><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike></p></tbody><option id="pjuwb"></option><strike id="pjuwb"></strike><u id="pjuwb"></u><td id="pjuwb"><center id="pjuwb"><tr id="pjuwb"></tr></center></td><em id="pjuwb"><mark id="pjuwb"><em id="pjuwb"><tt id="pjuwb"></tt></em></mark></em><strong id="pjuwb"></strong><wbr id="pjuwb"></wbr><s id="pjuwb"></s><strong id="pjuwb"></strong><legend id="pjuwb"></legend><nav id="pjuwb"></nav><dl id="pjuwb"><th id="pjuwb"><dl id="pjuwb"></dl></th></dl><noframes id="pjuwb"><ins id="pjuwb"></ins></noframes><font id="pjuwb"></font><strike id="pjuwb"><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"></label></style></i></strike><output id="pjuwb"></output><thead id="pjuwb"><pre id="pjuwb"></pre></thead><source id="pjuwb"></source><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem><pre id="pjuwb"><span id="pjuwb"><pre id="pjuwb"><big id="pjuwb"></big></pre></span></pre><cite id="pjuwb"><fieldset id="pjuwb"><s id="pjuwb"><rt id="pjuwb"></rt></s></fieldset></cite><big id="pjuwb"><progress id="pjuwb"><big id="pjuwb"></big></progress></big><samp id="pjuwb"><delect id="pjuwb"></delect></samp><dl id="pjuwb"></dl><strike id="pjuwb"><nav id="pjuwb"><dl id="pjuwb"><strong id="pjuwb"></strong></dl></nav></strike><tbody id="pjuwb"><b id="pjuwb"><optgroup id="pjuwb"><rp id="pjuwb"></rp></optgroup></b></tbody><em id="pjuwb"></em><xmp id="pjuwb"><blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote></xmp> <i id="pjuwb"><abbr id="pjuwb"><i id="pjuwb"><abbr id="pjuwb"></abbr></i></abbr></i><center id="pjuwb"><acronym id="pjuwb"><center id="pjuwb"></center></acronym></center><pre id="pjuwb"></pre><ul id="pjuwb"><thead id="pjuwb"></thead></ul><blockquote id="pjuwb"><pre id="pjuwb"><sup id="pjuwb"></sup></pre></blockquote><acronym id="pjuwb"></acronym><big id="pjuwb"><s id="pjuwb"></s></big><th id="pjuwb"></th><th id="pjuwb"></th><tbody id="pjuwb"></tbody><thead id="pjuwb"><strike id="pjuwb"></strike></thead><th id="pjuwb"><dl id="pjuwb"><wbr id="pjuwb"></wbr></dl></th><dl id="pjuwb"><strong id="pjuwb"></strong></dl><abbr id="pjuwb"><noframes id="pjuwb"><noscript id="pjuwb"></noscript></noframes></abbr><td id="pjuwb"><ol id="pjuwb"></ol></td><li id="pjuwb"><noscript id="pjuwb"><abbr id="pjuwb"></abbr></noscript></li><small id="pjuwb"><bdo id="pjuwb"><nav id="pjuwb"></nav></bdo></small><style id="pjuwb"></style><optgroup id="pjuwb"><table id="pjuwb"></table></optgroup><center id="pjuwb"><tr id="pjuwb"><dfn id="pjuwb"></dfn></tr></center><th id="pjuwb"></th><u id="pjuwb"></u><tfoot id="pjuwb"><legend id="pjuwb"><i id="pjuwb"></i></legend></tfoot><mark id="pjuwb"></mark><meter id="pjuwb"></meter><nav id="pjuwb"></nav><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><nobr id="pjuwb"></nobr><sub id="pjuwb"><th id="pjuwb"><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem></th></sub><thead id="pjuwb"><sub id="pjuwb"></sub></thead><ul id="pjuwb"><address id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></address></ul><dfn id="pjuwb"></dfn><pre id="pjuwb"></pre><input id="pjuwb"><cite id="pjuwb"><fieldset id="pjuwb"></fieldset></cite></input><u id="pjuwb"><form id="pjuwb"><u id="pjuwb"></u></form></u><kbd id="pjuwb"><em id="pjuwb"><mark id="pjuwb"></mark></em></kbd><tr id="pjuwb"></tr><del id="pjuwb"><form id="pjuwb"><address id="pjuwb"></address></form></del><tfoot id="pjuwb"><legend id="pjuwb"><ol id="pjuwb"><dl id="pjuwb"></dl></ol></legend></tfoot><menu id="pjuwb"><nobr id="pjuwb"><th id="pjuwb"><nobr id="pjuwb"></nobr></th></nobr></menu><fieldset id="pjuwb"></fieldset><pre id="pjuwb"><blockquote id="pjuwb"><samp id="pjuwb"></samp></blockquote></pre><xmp id="pjuwb"><sup id="pjuwb"><pre id="pjuwb"></pre></sup></xmp><span id="pjuwb"><progress id="pjuwb"></progress></span><font id="pjuwb"></font><var id="pjuwb"><abbr id="pjuwb"></abbr></var><strong id="pjuwb"><label id="pjuwb"><i id="pjuwb"><legend id="pjuwb"></legend></i></label></strong><tr id="pjuwb"><em id="pjuwb"><em id="pjuwb"><output id="pjuwb"></output></em></em></tr><thead id="pjuwb"><strike id="pjuwb"></strike></thead> <acronym id="pjuwb"></acronym><i id="pjuwb"></i><tt id="pjuwb"></tt><rt id="pjuwb"><source id="pjuwb"><rt id="pjuwb"></rt></source></rt><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike><del id="pjuwb"></del><font id="pjuwb"><output id="pjuwb"><ins id="pjuwb"><output id="pjuwb"></output></ins></output></font><kbd id="pjuwb"><tr id="pjuwb"><kbd id="pjuwb"></kbd></tr></kbd><pre id="pjuwb"><sup id="pjuwb"><delect id="pjuwb"><samp id="pjuwb"></samp></delect></sup></pre><samp id="pjuwb"></samp><track id="pjuwb"></track><tr id="pjuwb"></tr><center id="pjuwb"></center><fieldset id="pjuwb"></fieldset><i id="pjuwb"></i><td id="pjuwb"></td><rt id="pjuwb"></rt><object id="pjuwb"></object><pre id="pjuwb"><progress id="pjuwb"><sub id="pjuwb"><thead id="pjuwb"></thead></sub></progress></pre><kbd id="pjuwb"><tr id="pjuwb"><option id="pjuwb"></option></tr></kbd><output id="pjuwb"><ins id="pjuwb"></ins></output><ol id="pjuwb"></ol><source id="pjuwb"></source><strong id="pjuwb"></strong><ruby id="pjuwb"></ruby><sub id="pjuwb"><meter id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></meter></sub><pre id="pjuwb"></pre><center id="pjuwb"></center><tr id="pjuwb"><tbody id="pjuwb"><xmp id="pjuwb"><dd id="pjuwb"></dd></xmp></tbody></tr><video id="pjuwb"></video><pre id="pjuwb"></pre><form id="pjuwb"><optgroup id="pjuwb"></optgroup></form><samp id="pjuwb"></samp><kbd id="pjuwb"></kbd><strong id="pjuwb"><option id="pjuwb"></option></strong><object id="pjuwb"></object><abbr id="pjuwb"><noframes id="pjuwb"><abbr id="pjuwb"></abbr></noframes></abbr><ul id="pjuwb"><del id="pjuwb"><button id="pjuwb"><pre id="pjuwb"></pre></button></del></ul><abbr id="pjuwb"></abbr><strong id="pjuwb"><code id="pjuwb"><strong id="pjuwb"></strong></code></strong><option id="pjuwb"></option><optgroup id="pjuwb"><bdo id="pjuwb"><code id="pjuwb"></code></bdo></optgroup><mark id="pjuwb"><em id="pjuwb"><font id="pjuwb"></font></em></mark><acronym id="pjuwb"><code id="pjuwb"></code></acronym><dl id="pjuwb"></dl><em id="pjuwb"></em><object id="pjuwb"><input id="pjuwb"><object id="pjuwb"></object></input></object><output id="pjuwb"><dd id="pjuwb"></dd></output><option id="pjuwb"><button id="pjuwb"><option id="pjuwb"></option></button></option><small id="pjuwb"></small></div> <a href="http://917729.com" target="_blank">国产最新精品精品你懂的</a>| <a href="http://xpj493.com" target="_blank">日韩视频在线观看免费</a>| <a href="http://ttdy20.com" target="_blank">国产一区二区看久久</a>| <a href="http://77777de.com" target="_blank">日韩午夜在线视频</a>| <a href="http://dfrllaser.com" target="_blank">欧美黄色片免费观看</a>| <a href="http://www1126v.com" target="_blank">欧美一区二区三区四区视频</a>| <a href="http://by2565.com" target="_blank">欧美日韩另类丝袜其他</a>| <a href="http://110488.com" target="_blank">在线观看一区二区精品视频</a>| <a href="http://yy0754.com" target="_blank">久久久av水蜜桃</a>| <a href="http://10669p.com" target="_blank">午夜日韩在线</a>| <a href="http://sz-changrong.com" target="_blank">国产精品影音先锋</a>| <a href="http://maomi998.com" target="_blank">欧美一级大片在线观看</a>| <a href="http://yh-hy.com" target="_blank">亚洲午夜一级</a>| <a href="http://89wbw.com" target="_blank">国产精品蜜臀在线观看</a>| <a href="http://zhongrenma.com" target="_blank">亚洲一区二区三区激情</a>| <a href="http://6faa.com" target="_blank">一区二区毛片</a>| <a href="http://leohacks.com" target="_blank">欧美午夜精品一区二区三区</a>| <a href="http://chunhuigk.com" target="_blank">在线亚洲精品</a>| <a href="http://www-68689.com" target="_blank">99精品国产99久久久久久福利</a>| <a href="http://hzdss.com" target="_blank">欧美精品久久久久久久</a>| <a href="http://bocai4488.com" target="_blank">日韩视频二区</a>| <a href="http://llamkos.com" target="_blank">夜色激情一区二区</a>| <a href="http://by2866.com" target="_blank">国产精品久久久久毛片大屁完整版</a>| <a href="http://goldteddy.com" target="_blank">av成人动漫</a>| <a href="http://zd-jm.com" target="_blank">一区二区三区不卡视频在线观看 </a>| <a href="http://p5555ww.com" target="_blank">午夜精品福利在线</a>| <a href="http://cz-sensor.com" target="_blank">国产精品亚洲综合一区在线观看</a>| <a href="http://677968.com" target="_blank">亚洲主播在线</a>| <a href="http://wo6wo.com" target="_blank">午夜老司机精品</a>| <a href="http://xing69.com" target="_blank">国产日韩欧美在线</a>| <a href="http://5773000.com" target="_blank">欧美日韩一区免费</a>| <a href="http://www-6410c.com" target="_blank">在线视频精品一区</a>| <a href="http://gdvapar.com" target="_blank">亚洲一区二区三区乱码aⅴ蜜桃女</a>| <a href="http://3838418.com" target="_blank">国产精品区免费视频</a>| <a href="http://6633kj.com" target="_blank">久久国产精品99国产精</a>| <a href="http://www4848xx.com" target="_blank">久久狠狠亚洲综合</a>| <a href="http://avse98.com" target="_blank">最新亚洲一区</a>| <a href="http://hehextv.com" target="_blank">一区二区三区视频在线 </a>| <a href="http://playav111.com" target="_blank">久久综合久久综合九色</a>| <a href="http://bjlaosha.com" target="_blank">久久久久久欧美</a>| <a href="http://www-800778.com" target="_blank">亚洲精品小视频在线观看</a>| <a href="http://zgztby.com" target="_blank">一区二区三区成人精品</a>| <a href="http://xxx6688.com" target="_blank">国产日产欧美精品</a>| <a href="http://www-88899.com" target="_blank">欧美黄污视频</a>| <a href="http://www47755.com" target="_blank">国产精品久久久久免费a∨大胸 </a>| <a href="http://szywsj.com" target="_blank">亚洲人精品午夜在线观看</a>| <a href="http://83mmmm.com" target="_blank">欧美日韩国产欧</a>| <a href="http://hjk56.com" target="_blank">欧美一区二区三区在线视频 </a>| <a href="http://sapronlee.com" target="_blank">亚洲精品一区二区三区99</a>| <a href="http://cctbdy.com" target="_blank">夜夜爽av福利精品导航</a>| <a href="http://wnboke.com" target="_blank">国产精品多人</a>| <a href="http://www4411n.com" target="_blank">在线一区日本视频</a>| <a href="http://wilcherish.com" target="_blank">欧美.www</a>| <a href="http://110488.com" target="_blank">欧美aaaaaaaa牛牛影院</a>| <a href="http://337105.com" target="_blank">国产伦精品一区二区三区</a>| <a href="http://lusaier.com" target="_blank">亚洲精品一区二区三区av</a>| <a href="http://amass-ic.com" target="_blank">在线成人激情视频</a>| <a href="http://by21999.com" target="_blank">日韩视频―中文字幕</a>| <a href="http://junhuatesu.com" target="_blank">欧美日韩免费观看一区三区</a>| <a href="http://yckjwb.com" target="_blank">性欧美18~19sex高清播放</a>| <a href="http://www-137999.com" target="_blank">久久精品导航</a>| <a href="http://www-tk8899.com" target="_blank">一本一本久久a久久精品牛牛影视</a>| <a href="http://jjy891.com" target="_blank">午夜久久电影网</a>| <a href="http://chinasck.com" target="_blank">一二美女精品欧洲</a>| <a href="http://9238479.com" target="_blank">欧美在线综合视频</a>| <a href="http://hankanzhan.com" target="_blank">中国女人久久久</a>| <a href="http://yw1396.com" target="_blank">久久久久天天天天</a>| <a href="http://x1317.com" target="_blank">亚洲欧美另类在线</a>| <a href="http://xiaobi13.com" target="_blank">免播放器亚洲一区</a>| <a href="http://xiaocao-av.com" target="_blank">欧美一区影院</a>| <a href="http://zisxks.com" target="_blank">欧美日韩一区二区三区视频</a>| <a href="http://xy3977.com" target="_blank">久久综合网hezyo</a>| <a href="http://152mu.com" target="_blank">国产精品久久久久久久久久久久</a>| <a href="http://xmjhyey.com" target="_blank">亚洲电影天堂av</a>| <a href="http://chenyirong.com" target="_blank">国产亚洲视频在线</a>| <a href="http://tingxihuan.com" target="_blank">一本一本a久久</a>| <a href="http://3dpasion.com" target="_blank">亚洲人成在线观看</a>| <a href="http://6u6uuu666.com" target="_blank">欧美在线资源</a>| <a href="http://6u6uuu666.com" target="_blank">欧美在线看片</a>| <a href="http://jxrisen.com" target="_blank">国产精品美女主播在线观看纯欲</a>| <a href="http://www205sihu.com" target="_blank">亚洲精品自在久久</a>| <a href="http://387www.com" target="_blank">亚洲国产乱码最新视频</a>| <a href="http://389746.com" target="_blank">久久国产婷婷国产香蕉</a>| <a href="http://yjizz08.com" target="_blank">欧美影视一区</a>| <a href="http://961318.com" target="_blank">国产美女一区二区</a>| <a href="http://3bmmtv.com" target="_blank">亚洲一二三区在线观看</a>| <a href="http://337795.com" target="_blank">亚洲视频一区二区在线观看</a>| <a href="http://749996.com" target="_blank">欧美紧缚bdsm在线视频</a>| <a href="http://394141.com" target="_blank">欧美成年视频</a>| <a href="http://lzklpc.com" target="_blank">在线观看欧美黄色</a>| <a href="http://avtb2120.com" target="_blank">久久国产精品72免费观看</a>| <a href="http://dsjgqc.com" target="_blank">久久精品30</a>| <a href="http://2061856.com" target="_blank">国产色产综合产在线视频</a>| <a href="http://797298.com" target="_blank">亚洲欧美激情诱惑</a>| <a href="http://8x27.com" target="_blank">久久精品国产一区二区电影</a>| <a href="http://cnxwlm.com" target="_blank">国产日产欧美a一级在线</a>| <a href="http://609005.com" target="_blank">午夜精品久久久久久久久久久久 </a>| <a href="http://3bmmxyz.com" target="_blank">亚洲综合视频网</a>| <a href="http://by4425.com" target="_blank">欧美日韩成人一区二区</a>| <a href="http://www-440450.com" target="_blank">亚洲欧洲日产国产综合网</a>| <a href="http://tinganji.com" target="_blank">最新中文字幕一区二区三区</a>| <a href="http://www-76577c.com" target="_blank">另类成人小视频在线</a>| <a href="http://xiuxiu124.com" target="_blank">欧美成人精精品一区二区频</a>| <a href="http://www36633.com" target="_blank">伊人成人在线视频</a>| <a href="http://china-cvct.com" target="_blank">久久午夜激情</a>| <a href="http://mengmujia.com" target="_blank">亚洲高清久久久</a>| <a href="http://sdsptl.com" target="_blank">一区二区三区视频在线看</a>| <a href="http://hhsp13.com" target="_blank">亚洲欧美日韩专区</a>| <a href="http://shanghaijiagu.com" target="_blank">美女精品自拍一二三四</a>| <a href="http://wxsanyuan.com" target="_blank">亚洲精品欧美激情</a>| <a href="http://hsxinbao.com" target="_blank">欧美精品一区二区三区蜜桃 </a>| <a href="http://hafenchen.com" target="_blank">亚洲色图综合久久</a>| <a href="http://vipaiqiyi.com" target="_blank">欧美视频一区二区三区…</a>| <a href="http://wwwiqiuxia.com" target="_blank">一区二区三区精品视频</a>| <a href="http://xjhzgy.com" target="_blank">亚洲欧美日韩在线不卡</a>| <a href="http://www-24333.com" target="_blank">亚洲国产精品一区</a>| <a href="http://xvideoav99.com" target="_blank">亚洲欧洲视频</a>| <a href="http://488f.com" target="_blank">欧美视频精品在线</a>| <a href="http://7343888.com" target="_blank">欧美亚洲自偷自偷</a>| <a href="http://mauhorng.com" target="_blank">欧美成人免费在线视频</a>| <a href="http://by5263.com" target="_blank">在线视频欧美日韩精品</a>| <a href="http://dailymailnepal.com" target="_blank">国产精品专区第二</a>| <a href="http://q731.com" target="_blank">久久一区二区精品</a>| <a href="http://3344568.com" target="_blank">亚洲精品视频在线</a>| <a href="http://taikonghua.com" target="_blank">久久久国产午夜精品</a>| <a href="http://bizhijidi.com" target="_blank">亚洲黄色在线观看</a>| <a href="http://www-438686.com" target="_blank">国产精品xxxav免费视频</a>| <a href="http://85181890.com" target="_blank">欧美在线国产</a>| <a href="http://18cgh.com" target="_blank">日韩一区二区电影网</a>| <a href="http://www-xj788.com" target="_blank">久久久视频精品</a>| <a href="http://aiqianfang.com" target="_blank">亚洲免费黄色</a>| <a href="http://by3799.com" target="_blank">一区在线免费观看</a>| <a href="http://lzklpc.com" target="_blank">欧美午夜电影在线</a>| <a href="http://lucky5888.com" target="_blank">久久激情网站</a>| <a href="http://df7166.com" target="_blank">一区二区三区高清视频在线观看 </a>| <a href="http://zyjxyx.com" target="_blank">99v久久综合狠狠综合久久</a>| <a href="http://www33779.com" target="_blank">午夜视频一区二区</a>| <a href="http://ks180.com" target="_blank">亚洲三级视频在线观看</a>| <a href="http://www57669.com" target="_blank">国产精品一区二区黑丝</a>| <a href="http://9kkkb.com" target="_blank">欧美v亚洲v综合ⅴ国产v</a>| <a href="http://95gun.com" target="_blank">亚洲欧美制服中文字幕</a>| <a href="http://215920.com" target="_blank">最新国产の精品合集bt伙计</a>| <a href="http://poqsoft.com" target="_blank">久久精品导航</a>| <a href="http://mide776.com" target="_blank">亚洲一区欧美二区</a>| <a href="http://www433444.com" target="_blank">亚洲国产综合视频在线观看</a>| <a href="http://sepapapa8888.com" target="_blank">国产精品日韩</a>| <a href="http://677679.com" target="_blank">欧美日韩八区</a>| <a href="http://airsixth.com" target="_blank">蜜臀av在线播放一区二区三区</a>| <a href="http://107766a.com" target="_blank">亚洲欧美日韩在线观看a三区</a>| <a href="http://www-44899.com" target="_blank">亚洲国产精品成人久久综合一区</a>| <a href="http://dh03.com" target="_blank">久久福利电影</a>| <a href="http://avtb2120.com" target="_blank">亚洲欧美日本国产有色</a>| <a href="http://caox8.com" target="_blank">亚洲乱亚洲高清</a>| <a href="http://ourskycity.com" target="_blank">激情综合五月天</a>| <a href="http://ztqsfw.com" target="_blank">国产伦精品一区二区三区免费</a>| <a href="http://www49853b.com" target="_blank">欧美韩日一区二区三区</a>| <a href="http://pabjzz.com" target="_blank">久久久一区二区三区</a>| <a href="http://sygxjt.com" target="_blank">性色av一区二区三区</a>| <a href="http://shiselol.com" target="_blank">一区二区三区高清在线观看</a>| <a href="http://emu160.com" target="_blank">亚洲精品日韩久久</a>| <a href="http://quanfadq.com" target="_blank">亚洲第一中文字幕</a>| <a href="http://ddh345.com" target="_blank">免费成人黄色</a>| <a href="http://pppp95.com" target="_blank">久久综合五月</a>| <a href="http://www49966.com" target="_blank">久久久精品五月天</a>| <a href="http://2996611.com" target="_blank">欧美中文字幕视频在线观看</a>| <a href="http://ctmhotel.com" target="_blank">亚洲一区二区影院</a>| <a href="http://2061851.com" target="_blank">中文国产一区</a>| <a href="http://777177c.com" target="_blank">一区二区日韩</a>| <a href="http://www344399.com" target="_blank">日韩视频在线你懂得</a>| <a href="http://mom8888.com" target="_blank">在线观看的日韩av</a>| <a href="http://hbshwx.com" target="_blank">亚洲欧美成人在线</a>| <a href="http://739191g.com" target="_blank">99re6这里只有精品视频在线观看</a>| <a href="http://gaobb52.com" target="_blank">欧美电影免费观看高清</a>| <a href="http://weixiao668.com" target="_blank">久久伊人一区二区</a>| <a href="http://lymzdd.com" target="_blank">蜜臀久久99精品久久久久久9</a>| <a href="http://scratbag.com" target="_blank">久久精品视频在线</a>| <a href="http://621768.com" target="_blank">米奇777在线欧美播放</a>| <a href="http://9511331.com" target="_blank">亚洲精品中文字幕在线</a>| <a href="http://70909g.com" target="_blank">亚洲国产导航</a>| <a href="http://boocnn.com" target="_blank">亚洲国产精品热久久</a>| <a href="http://6633kj.com" target="_blank">91久久在线观看</a>| <a href="http://www-477499.com" target="_blank">最近看过的日韩成人</a>| <a href="http://wce-expo.com" target="_blank">亚洲精品视频在线观看免费</a>| <a href="http://szxrdr.com" target="_blank">亚洲国产人成综合网站</a>| <a href="http://hlyjh.com" target="_blank">亚洲精品久久久久久久久久久</a>| <a href="http://bjlaosha.com" target="_blank">亚洲黄色性网站</a>| <a href="http://viwasmart.com" target="_blank">亚洲靠逼com</a>| <a href="http://wwww999.com" target="_blank">一区二区电影免费观看</a>| <a href="http://toomicsvip.com" target="_blank">中国成人在线视频</a>| <a href="http://456316.com" target="_blank">午夜电影亚洲</a>| <a href="http://tom3958.com" target="_blank">久久福利影视</a>| <a href="http://hhbz518.com" target="_blank">久久在线精品</a>| <a href="http://163263.com" target="_blank">欧美精品久久99</a>| <a href="http://aaa798.com" target="_blank">国产精品青草久久久久福利99</a>| <a href="http://taoseav8.com" target="_blank">国产女人精品视频</a>| <a href="http://www11108b.com" target="_blank">国产综合网站</a>| <a href="http://www-90422.com" target="_blank">亚洲区国产区</a>| <a href="http://428368.com" target="_blank">亚洲综合国产激情另类一区</a>| <a href="http://080973.com" target="_blank">欧美伊人久久久久久午夜久久久久 </a>| <a href="http://haose23.com" target="_blank">国内成+人亚洲+欧美+综合在线</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>