可以把CreateThread函数的第四个参数pListDialogID传给回调函数的参数;
SSN_RETURN PiShowListDialog(__in SSN_OBJECT_ID ListType, __in SSN_OBJECT_ID ListDialogID)
{
if ((ListType.nCreaterPlugInId==SSN_UI_LIST_TYPE_LINK.nCreaterPlugInId)&&(ListType.nObjectRuntimeId==SSN_UI_LIST_TYPE_LINK.nObjectRuntimeId))
{
PSSN_OBJECT_ID pListDialogID=new SSN_OBJECT_ID;
*pListDialogID=ListDialogID;
HANDLE hThreadLink;
hThreadLink=CreateThread(NULL,0,FunLinkProc,pListDialogID,0,NULL);
CloseHandle(hThreadLink);
}
else
{
PSSN_OBJECT_ID pListDialogID=new SSN_OBJECT_ID;
*pListDialogID=ListDialogID;
HANDLE hThreadDefault;
hThreadDefault=CreateThread(NULL,0,FunDefaultProc,pListDialogID,0,NULL);
CloseHandle(hThreadDefault);
}
return SSN_OK;
}
pListDialogID=&ListDialogID; 是把指针指向&ListDialogID的地址;
*pListDialogID=ListDialogID; 是把值传给指针;
DWORD WINAPI FunDefaultProc(LPVOID lpParameter)//thread data
{
if(m_pDefaultList==NULL)
{
SSN_OBJECT_ID *tmpListDialogID= (SSN_OBJECT_ID*)lpParameter;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
m_pDefaultList=new CDlgDefaultList();
m_pDefaultList->SetListDialogID(*tmpListDialogID);
m_pDefaultList->DoModal();
delete pListDialogID;
}
else
{
m_pDefaultList->SetFocus();
}
return 0;
}