BS2OsdpStandardConfig config; if (!CommonControl.getOsdpStandardConfig(sdkContext, deviceID, out config)) return; UInt32 numOfActivated = 0; printOSDPDeviceID(ref config, ref numOfActivated); string tempStr = String.Format("How many devices do you want to remove? (0~{0})", numOfActivated); Util.HighlightLineMulti(tempStr, "How many", "remove"); Console.Write(">>>> "); int numOfDevice = Util.GetInput(1); if (0 < numOfDevice) { List removeIDs = new List(); for (int idx = 0; idx < numOfDevice; idx++) { tempStr = String.Format(">>>> [{0}] Please enter the slave ID to be removed.", idx + 1); Util.HighlightLine(tempStr, "device ID to be removed"); Console.Write(">>>> "); removeIDs.Add(Util.GetInput((UInt32)0)); } List listResult = new List(); int structSize = Marshal.SizeOf(typeof(UInt32)); IntPtr ptrArray = Marshal.AllocHGlobal(structSize * removeIDs.Length); long ptrCurrent = ptrArray.ToInt64(); BS2ErrorCode result = BS2ErrorCode.BS_SDK_SUCCESS; try { int[] tempIDs = Array.ConvertAll(removeIDs, Convert.ToInt32); Marshal.Copy(tempIDs, 0, ptrArray, tempIDs.Length); IntPtr outResultObj = IntPtr.Zero; UInt32 numOfResult = 0; result = (BS2ErrorCode)API.BS2_RemoveOsdpStandardDevice(sdkContext, deviceID, ptrArray, (UInt32)tempIDs.Length, out outResultObj, out numOfResult); if (result != BS2ErrorCode.BS_SDK_SUCCESS) { Console.WriteLine("Got error({0}).", result); } else { IntPtr curResult = outResultObj; int resultSize = Marshal.SizeOf(typeof(BS2OsdpStandardDeviceResult)); for (UInt32 resultIdx = 0; resultIdx < numOfResult; resultIdx++) { BS2OsdpStandardDeviceResult item = (BS2OsdpStandardDeviceResult)Marshal.PtrToStructure(curResult, typeof(BS2OsdpStandardDeviceResult)); //print(ref item, resultIdx); listResult.Add(item); curResult += resultSize; } API.BS2_ReleaseObject(outResultObj); Console.WriteLine("Call success."); } } finally { Marshal.FreeHGlobal(ptrArray); } } return result;