public CcmErrorCode GetErrorMessageStringForCode(int sessionId, uint errorCode, out string errorMessage) { var ptr = IntPtr.Zero; var result = Environment.Is64BitProcess ? CcmSdk64.CCMGetErrorMessageStringForCode(sessionId, errorCode, ref ptr) : CcmSdk32.CCMGetErrorMessageStringForCode(sessionId, errorCode, ref ptr); errorMessage = Marshal.PtrToStringUTF8(ptr); if (Environment.Is64BitProcess) { CcmSdk64.CCMFreeMemory(ptr); } else { CcmSdk32.CCMFreeMemory(ptr); } return((CcmErrorCode)result); }