L
lccc
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是Jeffrey Richter所写改进版同步对象中,记录结构的定义:<br> typedef struct {<br> DWORD m_dwSpinCount;<br> long m_lLockCount;<br> DWORD m_dwThreadId;<br> long m_lRecurseCount;<br> } SHAREDINFO, *PSHAREDINFO;<br><br> 我改为Delphi版本:<br> SHAREDINFO=packed record<br> m_dwSpinCountWORD; //spin计数<br> m_lLockCount:Integer; //锁定计数<br> m_dwThreadIdWORD; //拥有该临界段的线程ID<br> m_lRecurseCount:Integer; //本线程拥有该临界段的计数<br> end;<br> TSharedInformation=SHAREDINFO;<br> PSharedInformation=^TSharedInformation;<br><br> Jeffrey Richter将记录的一个字段作为了var参数传入函数InterlockedExchange中:<br> InterlockedExchange((PLONG) &m_pSharedInfo->m_dwSpinCount, dwSpinCount);<br> (这里将“(PLONG) &m_pSharedInfo->m_dwSpinCount”作为了var参数传入)<br> 但是,改为Delphi语法时,不能将记录的一个字段作为var参数传入,如何修改这个函数为Delphi格式?