コード例 #1
0
        protected NVDRS_SETTING?ReadSetting(IntPtr hSession, IntPtr hProfile, uint settingId)
        {
            var newSetting = new NVDRS_SETTING()
            {
                version = nvw.NVDRS_SETTING_VER,
            };

            var ssRes = nvw.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);

            if (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)
            {
                return(null);
            }

            if (ssRes != NvAPI_Status.NVAPI_OK)
            {
                throw new NvapiException("DRS_GetSetting", ssRes);
            }

            if (decrypter != null)
            {
                var profile = GetProfileInfo(hSession, hProfile);
                decrypter.DecryptSettingIfNeeded(profile.profileName, ref newSetting);
            }

            return(newSetting);
        }
コード例 #2
0
        private Profile CreateProfileForExport(IntPtr hSession, string profileName, bool includePredefined)
        {
            var result = new Profile();

            var hProfile = GetProfileHandle(hSession, profileName);

            if (hProfile != IntPtr.Zero)
            {
                result.ProfileName = profileName;

                var apps = GetProfileApplications(hSession, hProfile);
                foreach (var app in apps)
                {
                    result.Executeables.Add(app.appName);
                }

                var settings = GetProfileSettings(hSession, hProfile);
                foreach (var setting in settings)
                {
                    var isPredefined     = setting.isCurrentPredefined == 1;
                    var isCurrentProfile = setting.settingLocation ==
                                           NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION;

                    if (isCurrentProfile && (!isPredefined || includePredefined))
                    {
                        var exportSetting = setting;
                        _DecrypterService.DecryptSettingIfNeeded(profileName, ref exportSetting);

                        var profileSetting = ImportExportUitl
                                             .ConvertDrsSettingToProfileSetting(exportSetting);

                        result.Settings.Add(profileSetting);
                    }
                }
            }

            return(result);
        }