CnPack Forum


 
Subject: 我vista下delphi 2006加载CnWizards后没有响应的问题解决了
sweetgun
新警察
Rank: 1



UID 1462
Digest Posts 0
Credits 8
Posts 7
点点分 8
Reading Access 10
Registered 2005-12-11
Status Offline
Post at 2007-4-6 16:26  Profile | Blog | P.M. 
我vista下delphi 2006加载CnWizards后没有响应的问题解决了

下载了最新的cnpack和cnwizards源码,调试了一下就找到问题了。:-)

问题出在CnMsdnWizards引用的HtmlHlp.pas上,具体位置是CnWizards\Source\ThirdParty\HtmlHlp.pas。

具体原因是HtmlHlp加载hhctrl.ocx的函数有缺陷,某些情况下加载不了hhctrl.ocx,从而htmlhelp等函数指针都是空值,但是CnMsdnWizard.pas显然没有预料到这个问题,在initialization代码块里直接调用了HtmlHelp(0, nil, HH_INITIALIZE, DWORD(@g_dwCookie)); 出错。

function GetOCXPath(var Path: string): Boolean;
const
  ??HHPathRegKey = 'CLSID\{adb880a6-d8ff-11cf-9377-00aa003b7a11}\InprocServer32';
begin
  ??with TRegistry.Create do
  ??try
    ????RootKey := HKEY_CLASSES_ROOT;
    ????if OpenKeyReadOnly(HHPathRegKey) then Path := ReadString('');
    ????Result := (Path <> '') and FileExists(Path); // 在我的机器上path是%systemroot%/system32/hhctrl.ocx,FileExists不会处理环境变量,所以GetOcxPath返回false了。
  ??finally
    ????Free;
  ??end;
end;

所以解决问题的办法也很简单,在调用FileExists(Path)之前,先用ExpandEnvironmentStrings把环境变量替换掉就行了。说到这里,我实在很崇拜Delphi中对psapi等单元的包装,就算psapi.dll无法加载,对psapi.pas中的函数的调用也不会出错,当然函数调用都会返回false。

希望官方发布版本中尽快修正这个问题,用自己编译的总觉得不正宗。^_^
Top
sweetgun
新警察
Rank: 1



UID 1462
Digest Posts 0
Credits 8
Posts 7
点点分 8
Reading Access 10
Registered 2005-12-11
Status Offline
Post at 2007-4-6 16:43  Profile | Blog | P.M. 
还有一个小问题

CnWizards\Source\Thirdparty\GetIdeVersion.pas中用到的TVersionNumber与CnPack\Source\Common\CnCommon.pas中定义的TVersionNumber不一致,导致编译不过。不过和CnWizards\Bin\PSDeclEx\CnCommon.pas中反而是一样的。
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6812
Posts 3579
点点分 6812
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-4-6 22:47  Profile | Blog | P.M. 
非常感谢您的跟踪调试。

您所说的第二个问题,我们今天也已经解决了。

第一个问题我们测试一下,如果可以,我们会尽快修正的。
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6812
Posts 3579
点点分 6812
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2007-4-6 23:07  Profile | Blog | P.M. 
我们参考您的改法,改成了如下:

function GetOCXPath(var Path: string): Boolean;
const
  HHPathRegKey = 'CLSID\{adb880a6-d8ff-11cf-9377-00aa003b7a11}\InprocServer32';
var
  TmpStr: array[0..255] of Char;
begin
  with TRegistry.Create do
  try
    RootKey := HKEY_CLASSES_ROOT;
    if OpenKeyReadOnly(HHPathRegKey) then Path := ReadString('');
    FillChar(TmpStr, SizeOf(TmpStr), 0);
    ExpandEnvironmentStrings(PChar(Path), TmpStr, SizeOf(TmpStr));
    Path := TmpStr;
    Result := (Path <> '') and FileExists(Path);
  finally
    Free;
  end;
end;

我们网站上的最新构建版CnWizards 0.8.2.303 Unstable已经集成了此修改,
您能否下载此构建版本在VISTA上再测试一下?

http://www.cnpack.org/downbuilds.php
Top
sweetgun
新警察
Rank: 1



UID 1462
Digest Posts 0
Credits 8
Posts 7
点点分 8
Reading Access 10
Registered 2005-12-11
Status Offline
Post at 2007-4-8 19:07  Profile | Blog | P.M. 
太感谢了!已经用上了,没有问题
Top
 




All times are GMT++8, the time now is 2024-9-20 06:06

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007764 second(s), 8 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP