大家好!     我的问题如题目所述:::在  Delphi 中怎么启动 CHM 格式的帮助文件。在线等待!!!!!     ???????????????????????????????

解决方案 »

  1.   

    在线等待回答啊???那位前辈用Delphi 启动过CHM格式的文件啊 ???????????????????????
      

  2.   

    用shellexecute直接打开该文件
    shellexecute(handle,nil,pchar('c:\aa.chm'),nil,nil,sw_shownormal);
      

  3.   

    调用API 函数要在USES 里加入那个单元啊?????
      

  4.   

    在工程中包含下面的单元:unit HtmlHelpCommon;interfaceuses windows;type  DWORD_PTR = ^DWORD;function
      HtmlHelp(hwndCaller: HWnd; strFile: string;
      uCommand: UINT; dwData: DWORD_PTR): HWnd;procedure CloseHtmlHelp;implementationuses
      SysUtils;const
      dwCookie: DWORD = 0;var
      HHControlInstance: THandle = 0;
      HtmlHelpA: function(hwndCaller: HWnd; pszFile: PChar;
        uCommand: UINT; dwData: DWORD_PTR): HWnd; stdcall;
    function HtmlHelp(hwndCaller: HWnd; strFile: string;  uCommand: UINT; dwData: DWORD_PTR): HWnd;var
      LFileName: string;
      p: PChar;
      strOCX: string;
    begin
      if HHControlInstance = 0 then
      begin
        LFileName := StringOfChar(' ', 256);
        p := PChar(LFileName);
        GetSystemDirectory(p, 255);
        strOCX := StrCat(p, '\HHCTRL.OCX');
        HHControlInstance := LoadLibrary(p);
        if HHControlInstance = 0 then
          raise Exception.Create('HTML帮助系统没有安装!'#13' HTML帮助文件不能显示!');
        @HtmlHelpA := GetProcAddress(HHControlInstance, 'HtmlHelpA');
        if @HtmlHelpA = nil then
          raise Exception.Create('函数HTMLHELP不能装载!');
        HtmlHelpA(0, nil, $001C, (@dwCookie));
      end;
      result := HtmlHelpA(hwndCaller, PChar(strFile), uCommand, dwData);
    end;procedure CloseHtmlHelp;
    begin
      if HHControlInstance <> 0 then
      begin
        HtmlHelpA(0, nil, $001D, DWORD_PTR(dwCookie));
        FreeLibrary(HHControlInstance);
      end;
    end;end.
    ----------------------- end在窗口中调用:function TfrmMain.AppHtmlHelp(Command: Word; Data: Longint;
      var CallHelp: Boolean): Boolean;
    var
      ret: integer;
      Hfile: string;
    begin
      if not CallHelp then exit;
      Hfile := AppPath + Application.HelpFile;
      case Command of
        HELP_FINDER, HELP_CONTENTS:
          ret := HtmlHelp(handle, PChar(Hfile), $0001, nil);
        HELP_QUIT:
          ret := HtmlHelp(0, '', $0012, nil);
        HELP_CONTEXT:
          ret := HtmlHelp(handle, PChar(Hfile), $000F, DWORD_PTR(Data));
      end;
      result := ret <> 0;
      CallHelp := False;
    end;  Application.OnHelp := AppHtmlHelp;
      

  5.   

    shellexecute函数就行
    想打开什么就打开什么
      

  6.   

    楼上的谢谢你拉啊
    但是还是运行不通的
    用Shellexecute 打开后有没有API函数可以关掉的啊
      

  7.   

    ffwin() 太感谢你了啊 
    怎么给你加分啊我感觉这点分太少了
      

  8.   

    用shellexcuete打开怎么关闭啊 ?????????????????????????????????????????????????????????现在我能用shellexecute 打开CHM 帮助,但是我又关闭不了了啊 !请问怎么关闭用shellexecute 打开的CHM 呢?????????????????????????????????????????????????????????????????????????????????????????????????
      

  9.   

    要关掉就让拥护点关闭就行了么
    不过要代码控制的话,就不能用Shellexecute来执行,只能用类似CreateProcess的API来创建一个进程来运行CHM,CreateProcess会返回进程句柄,然后用这个句柄来释放进程,就可以关闭了
      

  10.   

    用ShellExecute(Handle,'open','hh.exe',filename,'',SW_SHOWNORMAL);
    就可以了
    HH.exe是windows自带的chm打开程序,这样比较简单
      

  11.   

    老大那关闭呢?拜托帮忙好不好
    我是写ERP的对WINDOWS内核方面的了解很少
      

  12.   

    写个公用的函数调用, 这样你的帮助文档资料就可以按下F1就能显示.Function HtmlHelp(hwd : integer; pszFile : String;
      uCommand :Integer;dwData :LongInt):integer;
      stdcall;external 'HHCtrl.ocx' name 'HtmlHelpA';窗体中, 处理帮助事件
    function TIniFrm.FormHelp(Command: Word; Data: Integer;
      var CallHelp: Boolean): Boolean;
    begin
      //call chm help file by helpcontext
      if HtmlHelp(Self.handle,'Help.chm',$000F,Data) = 0 then
      begin
        ShowMessage('Htm File Can't Open');
        Result := False;
      end
      else begin
        Result := True;
      end;
    end;
    这是我们一直在用这个方法来显示在线帮助文档资料.  但是现在我也遇到一个问题.  就是我用QUICKCHM软件打包的帮助文档就打不开, 如果使用OFFICE的就好了,   不知道为什么,  有那位能解释一下.