차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
ko:bs2_removeauthgroup [2017/06/28 11:35] 127.0.0.1 바깥 편집 |
ko:bs2_removeauthgroup [2022/06/27 15:40] (현재) mark [샘플코드] |
||
|---|---|---|---|
| 줄 21: | 줄 21: | ||
| ==== 함께 보기 ==== | ==== 함께 보기 ==== | ||
| [[BS2_GetAuthGroup]]\\ [[BS2_GetAllAuthGroup]]\\ [[BS2_SetAuthGroup]]\\ [[BS2_RemoveAllAuthGroup]] | [[BS2_GetAuthGroup]]\\ [[BS2_GetAllAuthGroup]]\\ [[BS2_SetAuthGroup]]\\ [[BS2_RemoveAllAuthGroup]] | ||
| + | |||
| + | |||
| + | ==== 샘플코드 ==== | ||
| + | C# | ||
| + | <code cpp> | ||
| + | Console.WriteLine("Enter the ID of the auth group which you want to remove: [ID_1,ID_2 ...]"); | ||
| + | Console.Write(">>>> "); | ||
| + | char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; | ||
| + | string[] authGroupIDs = Console.ReadLine().Split(delimiterChars); | ||
| + | List<UInt32> authGroupIDList = new List<UInt32>(); | ||
| + | |||
| + | foreach (string authGroupID in authGroupIDs) | ||
| + | { | ||
| + | if (authGroupID.Length > 0) | ||
| + | { | ||
| + | UInt32 item; | ||
| + | if (UInt32.TryParse(authGroupID, out item)) | ||
| + | { | ||
| + | authGroupIDList.Add(item); | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | if (authGroupIDList.Count > 0) | ||
| + | { | ||
| + | IntPtr authGroupIDObj = Marshal.AllocHGlobal(4 * authGroupIDList.Count); | ||
| + | IntPtr curAuthGroupIDObj = authGroupIDObj; | ||
| + | foreach (UInt32 item in authGroupIDList) | ||
| + | { | ||
| + | Marshal.WriteInt32(curAuthGroupIDObj, (Int32)item); | ||
| + | curAuthGroupIDObj = (IntPtr)((long)curAuthGroupIDObj + 4); | ||
| + | } | ||
| + | |||
| + | Console.WriteLine("Trying to remove auth gruops from device."); | ||
| + | result = (BS2ErrorCode)API.BS2_RemoveAuthGroup(sdkContext, deviceID, authGroupIDObj, (UInt32)authGroupIDList.Count); | ||
| + | |||
| + | Marshal.FreeHGlobal(authGroupIDObj); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | Console.WriteLine("Invalid parameter"); | ||
| + | } | ||
| + | </code> | ||