Example #1
0
        public CcmErrorCode GetApplicationInfo(int applicationId, out IcaApplication application)
        {
            var ptr = IntPtr.Zero;

            var result = Environment.Is64BitProcess ?
                         CcmSdk64.CCMGetApplicationInfo(applicationId, ref ptr) :
                         CcmSdk32.CCMGetApplicationInfo(applicationId, ref ptr);

            var appStruct = Marshal.PtrToStructure <CcmIcaApplication>(ptr);

            application = new IcaApplication()
            {
                ApplicationID = appStruct.ApplicationID,
                SessionID     = appStruct.SessionID,
                FriendlyName  = appStruct.FriendlyName,
                Title         = appStruct.Title,
                ClassName     = appStruct.ClassName,
                IconByteArray = PinvokeHelper.GetIconBytesFromIntPtr(appStruct.hIcon)
            };

            _ = Environment.Is64BitProcess ?
                CcmSdk64.CCMFreeICAApplication(1U, ptr) :
                CcmSdk32.CCMFreeICAApplication(1U, ptr);

            return((CcmErrorCode)result);
        }
Example #2
0
        public CcmErrorCode EnumerateApplications(out IcaApplication[] applications)
        {
            var ptrSize = Marshal.SizeOf(typeof(CcmIcaApplication));
            var ptr     = IntPtr.Zero;

            var result = Environment.Is64BitProcess ?
                         CcmSdk64.CCMEnumerateApplications(out var count, ref ptr) :
                         CcmSdk32.CCMEnumerateApplications(out count, ref ptr);

            applications = new IcaApplication[count];
            for (int i = 0; i < count; i++)
            {
                var nPtr      = IntPtr.Add(ptr, i * ptrSize);
                var appStruct = Marshal.PtrToStructure <CcmIcaApplication>(nPtr);

                var appDto = new IcaApplication()
                {
                    ApplicationID = appStruct.ApplicationID,
                    SessionID     = appStruct.SessionID,
                    FriendlyName  = appStruct.FriendlyName,
                    Title         = appStruct.Title,
                    ClassName     = appStruct.ClassName,
                    IconByteArray = PinvokeHelper.GetIconBytesFromIntPtr(appStruct.hIcon)
                };

                applications[i] = appDto;
            }

            _ = Environment.Is64BitProcess ?
                CcmSdk64.CCMFreeICAApplication(count, ptr) :
                CcmSdk32.CCMFreeICAApplication(count, ptr);

            return((CcmErrorCode)result);
        }