我用的是D6+WIN2000,CHM制作软件是:HTML HELP WORKSHOP 和 QUICKCHM2.6;
我要的是能实现:按F1实现联机帮助效果,不是用WINSHELL来启动帮助文件。
请大家帮忙!
另外我从网上也找了个帮助的制作说明,但是却达不到效果,提示说:...不是WINDOWS帮助文件,或者已被破坏。

解决方案 »

  1.   

    还要一个hh.exe文件和chm文件在一起
      

  2.   

    rayd(ray) : hh.exe是什么文件,起什么作用,怎么制作?谢谢!
      

  3.   

    uses HTMLHelp_Decl;...procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);beginif Key = Vk_F1 thenHtmlHelp(handle, 'xxx.chm',HH_DISPLAY_TOPIC, nil);end;
      

  4.   

    把我这个u_help.pas 加到工程里unit u_Help;interfaceuses
      Windows,  SysUtils,  Registry, dialogs, Forms,Messages;var
      HHCtrlHandle: THandle = 0; //0 if hhctrl.ocx could not be loaded
      //You can set this to false to override the default load API load on module initialization
      AutoLoadAPI: Boolean = TRUE;const
      hhctrlLib  = 'hhctrl.ocx';{exports}
      function  GetPathToHHCtrlOCX: string;
      procedure LoadHtmlHelp;
      procedure UnloadHtmlHelp;
      function  HelpTopic(sDispayTopic: string):boolean;  //调用主题页面
    { Externals from HHCTRL.OCX }
    var //functions are invalid if HHCtrlHandle = 0
      HtmlHelpA: function(hwndCaller: HWND; pszFile: PAnsiChar;
        uCommand: UInt; dwData: DWORD): HWND; stdcall;
      HtmlHelpW: function(hwndCaller: HWND; pszFile: PWideChar;
        uCommand: UInt; dwData: DWORD): HWND; stdcall;
      HtmlHelp: function(hwndCaller: HWND; pszFile: PChar;
        uCommand: UInt; dwData: DWORD): HWND; stdcall;
    { Commands to pass to HtmlHelp() }
    const
      HH_INITIALIZE = $001C; // Initializes the help system.
      HH_UNINITIALIZE = $001D; // Uninitializes the help system.
      HH_DISPLAY_TOC = $0001; // not currently implemented
      HH_DISPLAY_TOPIC = $0000;
      HH_HELP_CONTEXT = $000F; // display mapped numeric value in dwData
      HH_CLOSE_ALL = $0012; // close all windows opened directly or indirectly by the callerimplementationfunction GetWinSysDir: String;
    var path: array[0..260] of Char;
    begin
      GetSystemDirectory(path, SizeOf(path));
      result := path;
      if result[length(result)] = '\' then
        SetLength(result, length(result)-1);
    end;function GetPathToHHCtrlOCX: string;
    const hhPathRegKey = 'CLSID\{adb880a6-d8ff-11cf-9377-00aa003b7a11}\InprocServer32';
    {$IFDEF D4PLUS} // -- Delphi >=4 ------------
    var Reg: TRegistry;
    {$ENDIF}
    begin
    {$IFDEF D4PLUS} // -- Delphi >=4 ------------
      result := '';  //default return
      Reg := TRegistry.Create;
      Reg.RootKey := HKEY_CLASSES_ROOT;
      if Reg.OpenKeyReadOnly(hhPathRegKey) then  //safer call under NT
      begin
        result := Reg.ReadString('');  //default value
        Reg.CloseKey;
        if (result <> '') and (not FileExists(result)) then  //final check - file must exist
          result := '';
      end;
      Reg.Free;
    {$ELSE}         // -- Delphi <4 ------------
      Result := GetWinSysDir + '\hhctrl.ocx';
    {$ENDIF}
    end;//**********setup HTML Help API function interface *******************
    procedure LoadHtmlHelp;
    var OcxPath: string;
    begin
      if HHCtrlHandle = 0 then
      begin
        OcxPath := GetPathToHHCtrlOCX;
        if (OcxPath <> '') and FileExists(OcxPath) then
        begin
          HHCtrlHandle := LoadLibrary(PChar(OcxPath));
          if HHCtrlHandle <> 0 then
          begin
            @HtmlHelpA := GetProcAddress(HHCtrlHandle, 'HtmlHelpA');
            @HtmlHelpW := GetProcAddress(HHCtrlHandle, 'HtmlHelpW');
            @HtmlHelp := GetProcAddress(HHCtrlHandle, 'HtmlHelpA');
          end;
        end;
      end;
    end;procedure UnloadHtmlHelp;
    begin
      if HHCtrlHandle <> 0 then
      begin
        FreeLibrary(HHCtrlHandle);
        @HtmlHelpA := nil;
        @HtmlHelpW := nil;
        @HtmlHelp := nil;
        HHCtrlHandle := 0;
      end;
    end;//******************* 调用主题页面 *********************************************
    function HelpTopic(sDispayTopic: string):boolean;
    var
      irtn: integer;
      stmp: string;
    begin
      stmp :=  sDispayTopic;
      irtn := htmlhelp(GetDesktopWindow, PChar(stmp), HH_DISPLAY_TOPIC, 0);
      if irtn > 0 then
        SetForegroundWindow(irtn);
      if irtn <= 0 then
      begin
        Result := False;
        Application.MessageBox('帮助文件不存在!', '操作提示', MB_IconInformation + MB_SystemModal);
        exit;
      end;
      Result := True;
    end;initialization
      if AutoLoadAPI then
        LoadHtmlHelp;
    finalization
      UnloadHtmlHelp;
    end.
      

  5.   

    http://jjb.swaysoft.com/DownDetail.asp?id=38
      

  6.   

    在需要调用帮助的时候使用如下语句示例:procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key = 112 then HelpTopic('Help.chm::/' + '5.2.2.htm');
    end;例中的'5.2.2.htm'为对应的htm文件
      

  7.   

    aiirii(ari-爱的眼睛) :HTMLHelp_Decl是什么单元?能说明白点吗?或者给个DEMO
      

  8.   

    shindynj(一路奔走) :我的意思是写一个总的说明,只是在调用的时候CHM显示的是应该显示的帮助主题。你的意思好象是写N个CHM,然后在分别调用吗?
      

  9.   

    当然不是N个CHM你编辑CHM的时候是用了很多的htm吧?function HelpTopic(sDispayTopic: string):boolean;这个函数的参数就是你要调用的该CHM文件里含的htm比如:你用1.htm 2.htm编译成了AA.chm,1.htm是录入功能的说明,2.htm是导出功能的说明那么你在程序里录入功能模块就用HelpTopic调1.htm……
      

  10.   

    先将做好的chm放到主目录下,
    然后再要调用的窗口中添加如下代码(其中myhelp.chm是做好的帮助文件)
    type
    procedure FormKeyDown(Sender: TObject; var Key: Word;
          Shift: TShiftState);
    //////////////////////////////
    implementationuses ShellAPI
    ///////////////////////////////
    procedure Tf_tiaojie.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
    if Key = VK_F1
    then
    ShellExecute(0,'open',pchar(ExtractFilePath(Application.Exename)+'myhelp.chm'),nil,nil,SW_SHOWNORMAL);end;
    这样就ok了
      

  11.   

    aiirii(ari-爱的眼睛)  fenghai4690(冯海) 说的都是单纯调用一个chm文件 不分页面 调用后chm文件显示的是首页我的方法可以根据需要 调用chm文件后显示不同的指定页面根据你的实际情况选择吧