为什么相同的字符串有时表现不同? (VB.NET COM接口)

发布于 2024-08-16 13:20:44 字数 504 浏览 5 评论 0原文

示例:

Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C:\temp\catalog.zip"
Dim sf As Object = Sh32.NameSpace(path)

->不起作用,sf = Nothing

Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C:\temp\catalog.zip"
Dim sf As Object = Sh32.NameSpace(path.ToString)

->有效

有什么想法吗?

显然,path = path.ToString,但是当用作 COM 参数时,它们的行为有所不同。

Example:

Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C:\temp\catalog.zip"
Dim sf As Object = Sh32.NameSpace(path)

-> does not work, sf = Nothing

Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C:\temp\catalog.zip"
Dim sf As Object = Sh32.NameSpace(path.ToString)

-> works

Any idea?

Clearly path = path.ToString, but they behave differently when used as COM parameters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里泪两行 2024-08-23 13:20:45

嗯,我不太了解 VB 和/或 COM 的细节,但也许字符串对象和字符串表示之间有区别?

看到有人“知情”解决这个难题应该很有趣;)

Hmm, I don't know the details of VB and/or COM well enough, but maybe there is a difference between a string object and a string representation?

Should be interesting to see someone "in the know" resolving the puzzle ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文