---
title: "c++中使用类成员函数做为线程函数"
author: "725137"
date: "2013-08-10T07:39:37Z"
tags: []
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2013-08-10T07:39:37Z"
id: 1922819
url: "https://725137.iteye.com/blog/1922819"
---

typedef unsigned (\_\_stdcall   CAdapterObj::* Fun )( void  );  
 typedef unsigned (\_\_stdcall   * pThread )( void * );  
 Fun func = (Fun)&CAdapterObj::ThreadFun;

 DWORD dwAddress;  
 memcpy(&dwAddress,&func ,sizeof(func ));

 pThread pThrd;  
 memcpy(&pThrd, &dwAddress, sizeof(pThrd));

 HANDLE handle  = (HANDLE) \_beginthreadex(NULL,0,pThrd, reinterpret\_cast&lt; void* &gt;(this) ,0,NULL);