차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 | |||
|
ko:bs2_querydevicelicense [2023/02/14 14:48] mashin |
ko:bs2_querydevicelicense [2023/03/02 16:03] (현재) kkshin |
||
|---|---|---|---|
| 줄 44: | 줄 44: | ||
| ==== 샘플코드(C++) ==== | ==== 샘플코드(C++) ==== | ||
| - | <file cpp sample_setdebugfilelogex.cpp> | + | <file cpp sample_bs2_querydevicelicense.cpp> |
| - | const char* CURRENT_DIR = "."; | + | int getDeviceLicense(void* context, BS2_DEVICE_ID id) |
| - | const int MAX_SIZE_LOG_FILE = 100; // 100MB | + | |
| - | int sdkResult = BS2_SetDebugFileLogEx(DEBUG_LOG_ALL, DEBUG_MODULE_ALL, CURRENT_DIR, MAX_SIZE_LOG_FILE); | + | |
| - | if (BS_SDK_SUCCESS != sdkResult) | + | |
| { | { | ||
| - | printf("BS2_SetDebugFileLogEx call failed: %d", sdkResult); | + | DeviceControl dc(context); |
| - | return; | + | BS2LicenseBlob licenseBlob = { 0, }; |
| + | vector<BS2LicenseResult> licenseResult; | ||
| + | int sdkResult = BS_SDK_SUCCESS; | ||
| + | |||
| + | BS2_LICENSE_TYPE licenseType = (BS2_LICENSE_TYPE)Utility::getInput<uint32_t>("Enter the license type. (0: None, 1: Visual QR)"); | ||
| + | sdkResult = dc.queryDeviceLicense(id, licenseType, licenseResult); | ||
| + | if (BS_SDK_SUCCESS == sdkResult) | ||
| + | DeviceControl::print(licenseResult); | ||
| + | |||
| + | return sdkResult; | ||
| } | } | ||
| - | </file> | ||
| - | ==== 샘플코드(C#) ==== | + | int DeviceControl::queryDeviceLicense(BS2_DEVICE_ID id, BS2_LICENSE_TYPE licenseType, vector<BS2LicenseResult>& licenseResult) |
| - | <file csharp sample_setdebugfilelogex.cs> | + | |
| - | const string CURRENT_DIR = "."; | + | |
| - | const int MAX_SIZE_LOG_FILE = 100; // 100MB | + | |
| - | IntPtr ptrDir = Marshal.StringToHGlobalAnsi(CURRENT_DIR); | + | |
| - | result = (BS2ErrorCode)API.BS2_SetDebugFileLogEx(Constants.DEBUG_LOG_OPERATION_ALL, Constants.DEBUG_MODULE_ALL, ptrDir, MAX_SIZE_LOG_FILE); | + | |
| - | Marshal.FreeHGlobal(ptrDir); | + | |
| - | if (result != BS2ErrorCode.BS_SDK_SUCCESS) | + | |
| { | { | ||
| - | Console.WriteLine("Got error({0}).", result); | + | BS2LicenseResult* result = NULL; |
| - | return; | + | uint32_t numOfResult = 0; |
| + | int sdkResult = BS2_QueryDeviceLicense(context_, id, licenseType, &result, &numOfResult); | ||
| + | if (BS_SDK_SUCCESS != sdkResult) | ||
| + | { | ||
| + | TRACE("BS2_QueryDeviceLicense call failed: %d", sdkResult); | ||
| + | return sdkResult; | ||
| + | } | ||
| + | |||
| + | licenseResult.clear(); | ||
| + | for (uint32_t idx = 0; idx < numOfResult; idx++) | ||
| + | { | ||
| + | licenseResult.push_back(result[idx]); | ||
| + | } | ||
| + | |||
| + | return sdkResult; | ||
| } | } | ||
| </file> | </file> | ||
| + | |||
| + | ==== 샘플코드(C#) ==== | ||
| + | |||
| + | <file csharp sample_bs2_querydevicelicense.cs> | ||
| + | Console.WriteLine("Trying to get a license"); | ||
| + | |||
| + | Console.WriteLine("Enter the license type. (0: None, 1: Visual QR)"); | ||
| + | Console.Write(">>>> "); | ||
| + | UInt16 licenseType = Util.GetInput((UInt16)BS2LicenseType.VISUAL_QR_MASK); | ||
| + | |||
| + | IntPtr resultObj = IntPtr.Zero; | ||
| + | UInt32 numOfResult = 0; | ||
| + | |||
| + | BS2ErrorCode result = (BS2ErrorCode)API.BS2_QueryDeviceLicense(sdkContext, deviceID, licenseType, out resultObj, out numOfResult); | ||
| + | |||
| + | if (BS2ErrorCode.BS_SDK_SUCCESS != result) | ||
| + | { | ||
| + | Console.WriteLine("Got error({0}).", result); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | IntPtr curResult = resultObj; | ||
| + | int resultSize = Marshal.SizeOf(typeof(BS2LicenseResult)); | ||
| + | for (UInt32 idx = 0; idx < numOfResult; idx++) | ||
| + | { | ||
| + | BS2LicenseResult item = (BS2LicenseResult)Marshal.PtrToStructure(curResult, typeof(BS2LicenseResult)); | ||
| + | print(item, idx); | ||
| + | curResult += resultSize; | ||
| + | } | ||
| + | |||
| + | API.BS2_ReleaseObject(resultObj); | ||
| + | } | ||
| + | </file> | ||
| + | |||