ksmloh

ksmloh

  • NA
  • 42
  • 0

setting peer information the c# way

Dec 28 2003 12:19 PM
Can anyone convert the following codes to C#? HRESULT CDirectPlay8Peer::SetPlayerName( char *pPlayerName ) { HRESULT hr; WCHAR wszData[ STR_MAX ]; mbstowcs( wszData, pPlayerName, STR_MAX ); DPN_PLAYER_INFO dpnPlayerInfo; ZeroMemory( &dpnPlayerInfo, sizeof( DPN_PLAYER_INFO) ); dpnPlayerInfo.dwSize = sizeof( DPN_PLAYER_INFO ); dpnPlayerInfo.dwInfoFlags = DPNINFO_NAME; dpnPlayerInfo.pwszName = wszData; hr = m_pDP->SetPeerInfo( &dpnPlayerInfo, 0, 0, DPNSETPEERINFO_SYNC ); return true; } I know we can import [DllImport("msvcrt.dll", CharSet=CharSet.Ansi)] public unsafe static extern int mbstowcs(string wcstr, char* mbstr, int count ); but i dont know how to continue the rest... in C#, the dpnPlayerInfo has SetData(byte[]) but I could not find any doc. that would point out where I should put the name.

Answers (2)