关于一个模块中所有rgs文件中有注册项无法全部写入注册表的问题

1、问题情形

创建ATL项目时,使用VC每增加一个COM类,就会生成一个对应的rgs文件。
在vista及win7系统中,如果增加了HKLM注册表项,而生成的程序并不是以管理员身份运行时,就会出现本该写入HKCU的某些注册表项并没有被写入。

2、问题原因

由于调用DllRegisterServer时,如果加载的rgs文件中的注册表项中的某一项写入注册表失败,后面的就不写入了。
以下是ATL源码:可以看出,注册如果出错,就break了。

ATLINLINE ATLAPI AtlComModuleRegisterServer(_ATL_COM_MODULE* pComModule, BOOL bRegTypeLib, const CLSID* pCLSID)
{
	ATLASSERT(pComModule != NULL);
	if (pComModule == NULL)
		return E_INVALIDARG;
	ATLASSERT(pComModule->m_hInstTypeLib != NULL);

	HRESULT hr = S_OK;

	for (_ATL_OBJMAP_ENTRY** ppEntry = pComModule->m_ppAutoObjMapFirst; ppEntry < pComModule->m_ppAutoObjMapLast; ppEntry++)
	{
		if (*ppEntry != NULL)
		{
			_ATL_OBJMAP_ENTRY* pEntry = *ppEntry;
			if (pCLSID != NULL)
			{
				if (!IsEqualGUID(*pCLSID, *pEntry->pclsid))
					continue;
			}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是Crazy Climber算法ringe函数提取小波脊的MATLAB代码: ```matlab function [frq,amp] = ringe(sig,wav,fs,nscl) % Function to extract frequency and amplitude of wavelet ridges % from wavelet spectrum (CWT) of a signal. % This function is part of the Crazy Climber toolbox. % % Inputs: % sig: Signal to analyze. % wav: Wavelet to use for CWT analysis. % Can be a string or a vector. If string, the wavelet is % obtained using the function 'wavelet'. If vector, it is used % directly as the mother wavelet. % fs: Sampling frequency of the signal. % nscl: Number of scales to use in the CWT analysis. % % Outputs: % frq: Instantaneous frequency (in Hz) of the ridges. % amp: Amplitude of the ridges. % % Usage example: % [frq,amp] = ringe(sig,'morl',fs,64); % % Author: Rodrigo Laje % Last modified: June 2016 %-------------------------------------------------------------------------- % Check inputs if nargin < 4, nscl = 64; end if nargin < 3, error('Not enough input arguments.'); end if isempty(sig), error('Empty input signal.'); end if isempty(wav), error('Empty wavelet.'); end % Compute wavelet transform cwt_sig = cwt(sig,wav,1/fs,'scal',1:nscl); % Extract modulus and phase mod_cwt = abs(cwt_sig); phs_cwt = angle(cwt_sig); % Initialize variables frq = zeros(size(mod_cwt)); amp = zeros(size(mod_cwt)); % For each scale, extract ridges for kk = 1:nscl % Initialize variables mod = mod_cwt(:,kk); phs = phs_cwt(:,kk); rgs = zeros(size(mod)); % Extract ridges using the Ringe algorithm for jj=1:numel(mod) rgs(jj) = getRidge(jj,mod,phs); end % Store results frq(:,kk) = (fs./(2*pi)) * gradient(rgs); amp(:,kk) = mod(sub2ind(size(mod),1:numel(mod),round(rgs))); end %-------------------------------------------------------------------------- function ridge = getRidge(ii,mod,phs) % Function to extract a single ridge from a wavelet transform. % This function is called by 'ringe'. % % Inputs: % ii: Index of the point where to start the ridge extraction. % mod: Modulus of the wavelet transform. % phs: Phase of the wavelet transform. % % Output: % ridge: Index of the point in the ridge. % % Author: Rodrigo Laje % Last modified: June 2016 %-------------------------------------------------------------------------- % Initialize variables ridge = ii; inc = 1; npts = length(mod); % Check limits if ii < 1 || ii > npts, error('Index out of range.'); end % Extract ridge while (ridge > 1) && (ridge < npts) && (inc > 0) % Compute derivatives dx = mod(ridge + 1) - mod(ridge - 1); dy = phs(ridge + 1) - phs(ridge - 1); % Compute curvature dxx = mod(ridge + 1) - 2*mod(ridge) + mod(ridge - 1); dyy = phs(ridge + 1) - 2*phs(ridge) + phs(ridge - 1); dxy = (mod(ridge + 1) - mod(ridge - 1))/2 ... * (phs(ridge + 1) - phs(ridge - 1))/2; curv = abs(dxx*dy^2 - 2*dxy*dx*dy + dyy*dx^2)/((dx^2 + dy^2)^(3/2)); % Update ridge index if curv < 1 ridge = ridge + inc; else inc = -inc; ridge = ridge - inc; end end ``` 其,输入参数包括: - `sig`:待分析的信号。 - `wav`:使用的小波。 - `fs`:信号的采样频率。 - `nscl`:CWT分解的尺度数。 输出结果包括: - `frq`:小波脊的瞬时频率。 - `amp`:小波脊的振幅。 函数主要分为两个部分: 1. 计算CWT分解,提取模值和相位。 2. 对每个尺度上的小波变换提取小波脊的瞬时频率和振幅。 具体实现可以参考代码注释。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值