VB.NET - SHQueryRecycleBin 的问题
我目前正在开发一个供我个人使用的应用程序。这个想法是,你可以打开它并获取计算机的所有类型的统计信息(回收站、驱动器、网络等等)。现在我正在使用 Win API 中的 SHQueryRecycleBin
。
虽然我有一些问题。我尝试过寻找 VB6 或 VB.NET 解决方案的过时解决方案,但这些解决方案根本不起作用。我使用了此源 并检索我使用的文件的大小和数量 此来源。
我把它放在一个计时器中,在运行了 100 个刻度(正如我设置的那样)之后,我得到了这个错误:
File I/O of a structure with field 'cbSize' of type 'UInt32' is not valid.
cbSize
的类型是 UInteger
,它(显然)自动更改为 UInt32
- 我认为它是基于系统的。
您应该注意到,我使用的是 Windows 7 x86(64 位)。如果有比使用 Win API 更容易的此或另一段代码的解决方案,请告诉我。
我查看了 System.Management,但想要一个可以与大多数系统交互的防弹代码。
I'm currently working on an application for my personal use. The idea is that you can open it up and reach all kind of stats of your computer (Recycle bin, Drives, Network and much more). Now I was working with the SHQueryRecycleBin
from Win API.
Though I have some problems. And I've tried to look over outdated solutions for VB6 or VB.NET solutions that simply didn't work. I used the code reference from this source and to retrieve the size and count of files I used this source.
I put it in an timer, and after those 100 ticks (as I set it) were ran, I got this error:
File I/O of a structure with field 'cbSize' of type 'UInt32' is not valid.
The type of cbSize
is UInteger
which (apparently) automatic changes to an UInt32
- I think it's based on the system.
You should note that I'm on an Windows 7 x86 (64-bit). If have an solution for this or another piece of code that is easier than use Win API, let me know.
I have looked at the System.Management
but wanted an bullet proof code that could interact with most systems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有方便测试的 vb.net,但以下代码在 vb6 中运行得很好:
在模块中:
在表单中:
注意“货币”类型的使用 - 这是因为 vb6 没有正常的64 位整数的数据类型。类型
Currency
使用 8 个字节,但保留 4 位小数,因此乘以 10000 即可得到结果。I don't have vb.net handy to test, but the following code works perfectly well in vb6:
In a module:
And in a form:
Note the use of type "currency" - this is because vb6 doesn't have a normal data type for 64-bit integers. Type
Currency
is using 8 bytes, but keeps 4 decimal places, hence the multiplication by 10000 to get the results.