原来在VB6.0中使用的API函数,在VB.Net中无法使用,请各位高手帮帮忙

gthreebao 2005-09-01 12:16:20
原来我在VB6.0中使用
Private Declare Function ApiHtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" _
(ByVal hwndCaller As Long, _
ByVal pszFile As String, _
ByVal uCommand As Long, _
ByRef dwData As Any) As Long
Private Const HH_DISPLAY_TOPIC As Long = &H0
Private Const HH_HELP_CONTEXT As Long = &HF ' display mapped numeric
Private Const HH_CLOSE_ALL As Long = &H12 ' close all windows opened

这个API函数来调用“.chm”的帮助文件,并且可以定位到具体的目录,
现在的问题是:
我在VB.Net中使用这个API函数,不能正常的调用帮助文件,看到.Net里有Help这个类,里面有ShowHelp方法,但是试了好几次也不能实现定位到具体目录的功能。
求教:原来的API函数在.Net里面还能正常使用吗?如果可以,谁能教我具体的方法?
ShowHelp方法能实现我的需求吗?如果可以,应该怎么做?

研究了半天没有结果,请各位高手一定要帮帮忙,谢谢了!!
...全文
189 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
gthreebao 2005-09-07
  • 打赏
  • 举报
回复
问题已解决,原来离成功只差一步,哈哈哈,放粪
gdizqzq 2005-09-02
  • 打赏
  • 举报
回复
up 关注中
sunmoonfly 2005-09-01
  • 打赏
  • 举报
回复
不用api这么麻烦吧
一:在工具栏拖一个helpProvider 控件
二:把helpProvider控件属性name改成你的 chm路径,最好是相对路径
三: 在click事件写上
Help.ShowHelp(Me, HelpWuye.HelpNamespace) 'helpwuye,是你的helpprovider控件名


就可以调用了
libingao 2005-09-01
  • 打赏
  • 举报
回复
先添加引用:
using System.Runtime.InteropServices; //调用外方的 DLL 文件


//以下为调用外方 DLL 的引用
[DllImport("kernel32.dll")]
public static extern void Sleep(long dwMilliseconds);
[DllImport("kernel32.dll")]
public static extern long GetComputerName(ref string lpBuffer,long nSize); [DllImport("user32.dll")]
public static extern long LoadCursor(long hInstance,long lpCursorName);
[DllImport("user32.dll")]
public static extern long SetCursor (long hCursor);

//便可在程序中使用以上函数了。
//以上为 VC#.NET 中的用法。在 VB.NET 中可采用同样的方法。
//具体可参考 .NET 中帮助:System.Runtime.InteropServices 或者:
System.InteropServices.DllImportAttribute
gthreebao 2005-09-01
  • 打赏
  • 举报
回复
现在我用showhelp(me,"mspaint.chm","mspaint.chm::/paint_brush.htm")这种方式来调用帮助文件中指定的内容,这种方式一定要知道chm文件在编译前Html文件的名字,这种方式是可以指定位置了,但是光标却不能定在相应的目录上,比起原来API的调用还差一点,但是API的调用我搞了一个下午也没成功,希望能有高手指点一下
pupo 2005-09-01
  • 打赏
  • 举报
回复
一般都可以用,注意类型就可以了!
pupo 2005-09-01
  • 打赏
  • 举报
回复
在vb.net中Long类型要换成integer类型才行
gthreebao 2005-09-01
  • 打赏
  • 举报
回复
其它都好说,关键是不用这个API,我怎么定位呢?不是光打开chm文件就完事了,痛苦啊
EricBai 2005-09-01
  • 打赏
  • 举报
回复
哦,对了,打开Chm帮助你可以用这个API
private declare function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (Byval hwnd as integer,byval lpOperation as string ,byval lpFile as string ,byval lpParameters as string ,byval lpDirectorxy as string,byval nShowCmd as integer) as integer

使用的时候这样,假如Chm文件存放于你程序的运行目录下:
ShellExecute(0,"Open",Application.StartupPath & "\帮助.chm","",Application.StartupPath,5)
gthreebao 2005-09-01
  • 打赏
  • 举报
回复
用ShowHelp怎么定位chm文件中具体的位置呢,比如要定位到目录中某个特定的内容?
ttjacky 2005-09-01
  • 打赏
  • 举报
回复
一:在工具栏拖一个helpProvider 控件
二:把helpProvider控件属性name改成你的 chm路径,最好是相对路径
三: 在click事件写上
Help.ShowHelp(Me, HelpWuye.HelpNamespace) 'helpwuye,是你的helpprovider控件名

同意这个方法,不依赖那个ocx
EricBai 2005-09-01
  • 打赏
  • 举报
回复
VB6转VB.net关于API的问题,最常见的就是Long整型的问题,你把原来代码中所有的Long整型换成Integer试试看。VB里面Long是32位的,VB.net Long是64位的,VB.net Integer 是32位的。

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧