亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? client.cpp

?? COM技術內(nèi)幕配書源碼
?? CPP
字號:
//
// Client.cpp - Client implementation
//
#include <windows.h> 
#include <stdlib.h>
#include <objbase.h>
#include <assert.h>

#define __OUTPROC_SERVER_ // To get the proper definition of trace
#include "Util.h"
#undef __OUTPROC_SERVER_ 

#include "Iface.h"
#include "Free.h"
#include "Cli-Free.h"

static inline void trace(char* msg)
	{ Util::Trace("Client", msg, S_OK) ;} 
static inline void trace(char* msg, HRESULT hr)
	{ Util::Trace("Client", msg, hr) ;}

///////////////////////////////////////////////////////////
//
// The client application
//

#include "resource.h"

///////////////////////////////////////////////////////////
//
// Global variables for main apartment
//
// Module handle
HINSTANCE g_hModule = NULL ;

// Handle to child listbox
HWND g_hWndListBox = NULL ;

// ID of the timer
static UINT g_TimerId  = 0 ;

// Pointer to the interface on our component
static IX* g_pIX = NULL ; 

// Pointers to free thread classes
CClientFree* g_pThread = NULL ;
CClientFree2* g_pThread2 = NULL ;

///////////////////////////////////////////////////////////
//
// Functions prototypes
//

// Create and initialize the main window.
HWND InitWindow(int nCmdShow) ;

// Create the child listbox control.
BOOL CreateChildListbox(HWND hWndParent, int cx, int cy) ;

// The main window procedure
extern "C" LONG APIENTRY MainWndProc(HWND hWnd,
                                     UINT message,
                                     UINT wParam,
                                     LONG lParam) ;

// InitializeThread - Create the free thread and the component.
BOOL InitializeThread(HWND hWndMain) ;

// Initialize the second thread.
BOOL InitializeThread2() ;

// Timer tick message handler
void OnTick() ;

// Delete and tidy.
void CleanUp(HWND hWnd) ;

///////////////////////////////////////////////////////////
//
// WinMain function
//
extern "C" int WINAPI WinMain( HINSTANCE hInstance, 
                               HINSTANCE hPrevInstance,
                               LPSTR lpCmdLine, 
                               int nCmdShow)
{
	// Initialize the COM Library.
	HRESULT hr = CoInitialize(NULL) ;
	if (FAILED(hr))
	{
		return 0 ;
	}
   
	// Create the main window.
	HWND hWndMain = InitWindow(nCmdShow) ;
	if (hWndMain)
	{
		// Initialize the thread.
		if (InitializeThread(hWndMain))
		{
			// Create the second thread.
			InitializeThread2() ;
		}

		// Wait for a message.
		MSG msg ;
		while (::GetMessage(&msg, 0, 0, 0) > 0)
		{
			::DispatchMessage(&msg) ;
		}
	}

	// Uninitialize the COM Library.
	CoUninitialize() ;
	return 0 ;
}


///////////////////////////////////////////////////////////
//
// Initialize window.
//
HWND InitWindow(int nCmdShow) 
{
	
	// Fill in window class structure with parameters
	// that describe the main window.
	WNDCLASS wcListview ;
	wcListview.style = 0 ;                     
	wcListview.lpfnWndProc =   (WNDPROC)MainWndProc ;
	wcListview.cbClsExtra =    0 ;
	wcListview.cbWndExtra =    0 ; 
	wcListview.hInstance =     g_hModule ;
	wcListview.hIcon =         ::LoadIcon(g_hModule,
	                                      MAKEINTRESOURCE(IDC_ICON)) ;
	wcListview.hCursor =       ::LoadCursor(NULL, IDC_ARROW) ;
	wcListview.hbrBackground = ::GetStockObject(WHITE_BRUSH) ;
	wcListview.lpszMenuName =  NULL;
	wcListview.lpszClassName = "MyServerWinClass" ;

	BOOL bResult = ::RegisterClass(&wcListview) ;
	if (!bResult)
	{
		return NULL ;
	}

	HWND hWndMain ;

	hWndMain = ::CreateWindow("MyServerWinClass",
	                          "Component Server", 
	                          WS_OVERLAPPEDWINDOW,
	                          CW_USEDEFAULT, CW_USEDEFAULT,
	                          CW_USEDEFAULT, CW_USEDEFAULT,
	                          NULL,               
	                          NULL,               
	                          g_hModule,          
	                          NULL) ;

	// If window could not be created, return "failure".
	if (!hWndMain)
	{
		return NULL ;
	}

	// Make the window visible; update its client area;
	// and return "success".
	::ShowWindow(hWndMain, nCmdShow) ;
	::UpdateWindow(hWndMain) ; 
	
	return hWndMain ;      
}

///////////////////////////////////////////////////////////
//
// Create the listbox child control in the main window.
//
BOOL CreateChildListbox(HWND hWndParent, int cx, int cy) 
{
	// Create a listbox for output.
	g_hWndListBox =
		::CreateWindow("LISTBOX",
		               NULL, 
		               WS_CHILD | WS_VISIBLE | LBS_USETABSTOPS
		                | WS_VSCROLL | LBS_NOINTEGRALHEIGHT,
		               0, 0, cx, cy,
		               hWndParent,
		               NULL,               
		               g_hModule,          
		               NULL) ;
	if (g_hWndListBox  == NULL)
	{
		// Listbox not created
		::MessageBox (NULL, "Listbox not created!", NULL, MB_OK );
		return FALSE ;
	}
	else
	{
		return TRUE ;
	}
}

///////////////////////////////////////////////////////////
//
// InitializeThread - Create the thread and the component.
//
BOOL InitializeThread(HWND hWnd)
{
	// Create a simple thread object.
	g_pThread = new CClientFree ;

	// Start the thread.
	if (g_pThread->StartThread())
	{
		trace("Successfully started thread.") ;

		// Create the component.
		HRESULT hr = g_pThread->CreateComponent(CLSID_Component,
		                                        IID_IX,
		                                        (IUnknown**)&g_pIX) ;
		if (SUCCEEDED(hr))
		{
			trace("Successfully created component.") ;
			// Initialize the component.
			HRESULT hr = g_pIX->SetStartCount(5000) ;
			if (FAILED(hr))
			{
				trace("SetStartCount failed.", hr) ; 
				return FALSE ;
			}

			// Start a timer.
			g_TimerId = SetTimer(hWnd, 369, 500, NULL) ;
			assert(g_TimerId != 0) ;
		}
		else
		{
			trace("Failed to create the component.") ;
			return FALSE ;
		}
	}
	else
	{
		trace("Failed starting thread.") ;
		return FALSE ;
	}

	return TRUE ;
}

///////////////////////////////////////////////////////////
//
// InitializeThread2
//   -  Create a second thread, but use the component
//      from the first thread.
//
BOOL InitializeThread2()
{
	if (g_pThread == NULL)
	{
		return FALSE ;
	}

	// Create the second thread.
	// This thread has a different WorkerFunction.
	g_pThread2 = new CClientFree2 ;

	// Start the thread.
	if (g_pThread2->StartThread())
	{
		trace("Successfully started second thread.") ;

		// Get the same pointer used by the first thread.
		IX* pIX = NULL ;
		pIX = g_pThread->ShareUnmarshaledInterfacePointer() ;
		assert(pIX != NULL) ;

		// Use this pointer in the second thread.
		g_pThread2->UseUnmarshaledInterfacePointer(pIX) ;
		pIX->Release() ;

		return TRUE ;
	}
	else
	{
		trace("Failed to start second thread.") ;

		return FALSE ;
	}
}

///////////////////////////////////////////////////////////
//
// OnTick - Called when the window gets a WM_TIMER message
//
void OnTick()
{
	if (g_pIX != NULL)
	{
		// Get the current count.
		long c = 0 ;
		HRESULT hr = g_pIX->GetCurrentCount(&c) ;
		assert(SUCCEEDED(hr)) ;

		char* pszhand ;
		BOOL bRightHand = FALSE ;
		hr = g_pIX->InRightHand(&bRightHand) ;
		assert(SUCCEEDED(hr)) ;
		if (bRightHand)
		{
			pszhand = "right" ;
		}
		else
		{
			pszhand = "left" ;
		}

		// Display the count.
		strstream sout ;
		sout << "The current count is : "
		     << c 
		     << " in the "
		     << pszhand
		     << "hand." 
		     << ends ;
		trace(sout.str()) ;
	}
}

///////////////////////////////////////////////////////////
//
// Main window procedure
//
extern "C" LONG APIENTRY MainWndProc(
	HWND hWnd,                // window handle
	UINT message,             // type of message
	UINT wParam,              // additional information
	LONG lParam)              // additional information
{
	DWORD dwStyle ;

	switch (message) 
	{
	case WM_CREATE:
		{
			// Create listbox control
			CREATESTRUCT* pcs = reinterpret_cast<CREATESTRUCT*>(lParam) ;
			if (!CreateChildListbox(hWnd, pcs->cx, pcs->cy))
			{
				return -1 ;
			}			
		}
		break ;

	case WM_SIZE:
		::MoveWindow(g_hWndListBox ,
		             0, 0,
		             LOWORD(lParam),
		             HIWORD(lParam),
		             TRUE) ;
		break ;

	case WM_TIMER:
		OnTick() ;
		break ;

	case WM_DESTROY:   // message: window being destroyed
		::PostQuitMessage(0) ;
		break ;

	case WM_CLOSE:
		CleanUp(hWnd) ;
		//Fall through 
	default:
		return (DefWindowProc(hWnd, message, wParam, lParam)) ;
	}
	return 0 ;
}

///////////////////////////////////////////////////////////
//
//	CleanUp
//
void CleanUp(HWND hWnd)
{
	// The list box is going away.
	g_hWndListBox = NULL ;

	// Kill the timer.
	if (g_TimerId != 0)
	{
		BOOL b = KillTimer(hWnd, g_TimerId) ;
		assert(b = TRUE) ;
		g_TimerId = 0 ;
	}

	// Remove interface pointer.
	if (g_pIX != NULL)
	{
		g_pIX->Release() ;
		g_pIX = NULL ;
	}

	if (g_pThread != NULL)
	{
		g_pThread->StopThread() ;
		delete g_pThread ;
		g_pThread = NULL ;
	}

	if (g_pThread2 != NULL)
	{
		g_pThread2->StopThread() ;
		delete g_pThread2 ;
		g_pThread2 = NULL ;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美aaaaaa午夜精品| 亚洲国产成人高清精品| 欧美专区亚洲专区| 国产一区二区91| 亚洲午夜免费电影| 最新欧美精品一区二区三区| 这里只有精品电影| 91麻豆国产自产在线观看| 麻豆成人久久精品二区三区小说| 亚洲色图视频免费播放| 久久在线观看免费| 欧美精品电影在线播放| 色婷婷综合久久久久中文 | 一区二区三区久久久| 精品日韩成人av| 欧美少妇一区二区| 色综合天天综合网天天看片| 国产一区二区三区精品欧美日韩一区二区三区 | 亚洲综合色成人| 国产三级欧美三级日产三级99| 欧美情侣在线播放| 91久久免费观看| 91小视频免费看| 成人黄色电影在线| 国产成人亚洲精品狼色在线| 蜜桃在线一区二区三区| 午夜精彩视频在线观看不卡| 最新成人av在线| 国产精品白丝在线| 中文av一区二区| 国产欧美视频一区二区| 国产日韩精品一区二区三区| 久久夜色精品一区| www一区二区| 26uuu国产一区二区三区| 日韩欧美一区在线观看| 欧美精品xxxxbbbb| 欧美一区二区三区免费| 欧美一区二区三区精品| 91麻豆精品国产91久久久久久| 欧美日韩成人综合在线一区二区| 91行情网站电视在线观看高清版| 色综合久久久网| 欧美主播一区二区三区美女| 欧美性欧美巨大黑白大战| 成人一区在线看| 美女免费视频一区二区| 日韩高清在线一区| 麻豆精品一区二区综合av| 久久精品99国产精品| 韩国女主播一区| 成人妖精视频yjsp地址| 99久久er热在这里只有精品15 | 国产剧情在线观看一区二区| 久久国产免费看| 国产精品一二三四五| 国产精品一区专区| av综合在线播放| 色av成人天堂桃色av| 欧美日韩一区不卡| 精品国产露脸精彩对白| 国产精品麻豆久久久| 香蕉久久一区二区不卡无毒影院 | 91小视频免费观看| 色婷婷精品久久二区二区蜜臀av| 在线欧美日韩精品| 日韩一区二区三区高清免费看看| 亚洲精品一区二区精华| 国产精品久久久久国产精品日日 | 国产成人精品亚洲日本在线桃色| 成人av在线电影| 欧美色综合网站| 欧美成人video| 自拍偷拍亚洲欧美日韩| 午夜久久久久久久久久一区二区| 久久99精品一区二区三区三区| 成人晚上爱看视频| 在线日韩av片| 国产亚洲欧美在线| 亚洲综合久久久| 狠狠色丁香九九婷婷综合五月| av电影在线观看完整版一区二区 | 亚洲视频一二三| 日本欧美一区二区三区| 国产mv日韩mv欧美| 欧美日韩国产电影| 国产精品久久网站| 久久精品久久综合| 91麻豆产精品久久久久久| 日韩一级二级三级| 亚洲美女视频一区| 国产一区二区三区免费| 欧美日韩国产在线观看| 中文字幕一区二区三区视频| 蜜臀久久久久久久| 色菇凉天天综合网| 久久久久国产免费免费| 舔着乳尖日韩一区| 日日摸夜夜添夜夜添国产精品| 亚洲国产精品影院| 成人黄页在线观看| 日韩欧美一区二区在线视频| 亚洲蜜臀av乱码久久精品| 国产精品自拍av| 91精品一区二区三区久久久久久| 国产精品理论在线观看| 美女看a上一区| 欧美日韩免费视频| 亚洲欧美日韩国产中文在线| 国产一区二区三区免费播放 | 国产精品免费视频观看| 蜜桃91丨九色丨蝌蚪91桃色| 欧美优质美女网站| 综合久久久久久| 大桥未久av一区二区三区中文| 日韩欧美一级二级三级| 亚洲高清一区二区三区| 在线免费不卡电影| 亚洲人精品一区| www.99精品| 国产精品午夜在线观看| 国产乱人伦偷精品视频免下载| 3d动漫精品啪啪1区2区免费| 午夜精品一区二区三区免费视频| 色悠久久久久综合欧美99| 国产精品对白交换视频| 成人性生交大片免费| 国产色综合久久| 国产麻豆欧美日韩一区| 久久综合久久99| 经典一区二区三区| 精品美女被调教视频大全网站| 青娱乐精品视频| 日韩欧美久久久| 精品一区二区免费| 26uuu亚洲综合色| 国内精品视频666| 久久蜜臀精品av| 国产精品99久久久久久有的能看| 久久久久久一二三区| 国产黄色精品网站| 国产精品国产三级国产三级人妇| 成人国产精品免费观看动漫| 国产精品国产精品国产专区不蜜 | 欧美色精品在线视频| 亚洲大片在线观看| 欧美一区二区三区在线看| 日韩av在线播放中文字幕| 欧美一区二区三区公司| 国产一区二区中文字幕| 国产片一区二区| 91丨porny丨国产| 亚洲chinese男男1069| 欧美一级理论片| 国产裸体歌舞团一区二区| 欧美极品xxx| 91福利区一区二区三区| 日韩在线a电影| 久久久亚洲精品石原莉奈 | 日韩写真欧美这视频| 狠狠色狠狠色合久久伊人| 国产人伦精品一区二区| 91麻豆视频网站| 男男视频亚洲欧美| 国产精品视频线看| 欧美午夜精品一区二区三区| 久久精品国产99久久6| 国产精品你懂的| 欧美日本韩国一区二区三区视频| 黄色日韩三级电影| 中文字幕一区二区在线观看| 欧美日免费三级在线| 韩国精品久久久| 一区二区三区四区亚洲| 日韩欧美的一区二区| 不卡视频一二三| 日本在线观看不卡视频| 中文字幕va一区二区三区| 欧美日韩国产综合一区二区| 国产精品一区久久久久| 亚洲va欧美va人人爽| 欧美国产精品v| 91精品在线免费观看| 成人av网站免费观看| 日韩成人伦理电影在线观看| 中文av一区二区| 日韩欧美中文字幕一区| 91亚洲精品久久久蜜桃| 久久福利资源站| 亚洲电影视频在线| 国产精品三级视频| 日韩一区二区在线免费观看| 91在线观看污| 韩国成人福利片在线播放| 亚洲一区二区三区爽爽爽爽爽| 国产婷婷精品av在线| 日韩一级二级三级| 欧美怡红院视频| 99re8在线精品视频免费播放| 久久国产欧美日韩精品|