차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 | |||
ko:bs2_removeauthgroup [2022/06/27 15:39] mark [함께 보기] |
ko:bs2_removeauthgroup [2022/06/27 15:40] (현재) mark [샘플코드] |
||
---|---|---|---|
줄 24: | 줄 24: | ||
==== 샘플코드 ==== | ==== 샘플코드 ==== | ||
- | C++ | + | C# |
<code cpp> | <code cpp> | ||
- | int UserControl::getUserBlobFaceAuthGroupID(BS2User& user) | + | Console.WriteLine("Enter the ID of the auth group which you want to remove: [ID_1,ID_2 ...]"); |
- | { | + | Console.Write(">>>> "); |
- | stringstream msg; | + | char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; |
- | msg << "Please enter a authentication group ID.\n"; | + | string[] authGroupIDs = Console.ReadLine().Split(delimiterChars); |
- | msg << "This is used for face authentication. [0: Not using]"; | + | List<UInt32> authGroupIDList = new List<UInt32>(); |
- | uint32_t authGroupID = Utility::getInput<uint32_t>(msg.str()); | + | |
- | user.authGroupID = authGroupID; | + | |
- | return BS_SDK_SUCCESS; | + | foreach (string authGroupID in authGroupIDs) |
+ | { | ||
+ | if (authGroupID.Length > 0) | ||
+ | { | ||
+ | UInt32 item; | ||
+ | if (UInt32.TryParse(authGroupID, out item)) | ||
+ | { | ||
+ | authGroupIDList.Add(item); | ||
+ | } | ||
+ | } | ||
} | } | ||
- | BS2_ReleaseObject(uidObj); | + | if (authGroupIDList.Count > 0) |
- | </code> | + | |
- | C# | + | |
- | <code cpp> | + | |
- | IntPtr authGroupIDObj = Marshal.AllocHGlobal(4 * authGroupIDList.Count); | + | |
- | IntPtr curAuthGroupIDObj = authGroupIDObj; | + | |
- | foreach (UInt32 item in authGroupIDList) | + | |
{ | { | ||
- | Marshal.WriteInt32(curAuthGroupIDObj, (Int32)item); | + | IntPtr authGroupIDObj = Marshal.AllocHGlobal(4 * authGroupIDList.Count); |
- | curAuthGroupIDObj = (IntPtr)((long)curAuthGroupIDObj + 4); | + | IntPtr curAuthGroupIDObj = authGroupIDObj; |
- | } | + | foreach (UInt32 item in authGroupIDList) |
+ | { | ||
+ | Marshal.WriteInt32(curAuthGroupIDObj, (Int32)item); | ||
+ | curAuthGroupIDObj = (IntPtr)((long)curAuthGroupIDObj + 4); | ||
+ | } | ||
- | Console.WriteLine("Trying to get auth gruops from device."); | + | Console.WriteLine("Trying to remove auth gruops from device."); |
- | result = (BS2ErrorCode)API.BS2_GetAuthGroup(sdkContext, deviceID, authGroupIDObj, (UInt32)authGroupIDList.Count, out authGroupObj, out numAuthGroup); | + | result = (BS2ErrorCode)API.BS2_RemoveAuthGroup(sdkContext, deviceID, authGroupIDObj, (UInt32)authGroupIDList.Count); |
- | Marshal.FreeHGlobal(authGroupIDObj); | + | Marshal.FreeHGlobal(authGroupIDObj); |
- | BS2_ReleaseObject(uidObj); | + | } |
+ | else | ||
+ | { | ||
+ | Console.WriteLine("Invalid parameter"); | ||
+ | } | ||
</code> | </code> |