469,922 Members | 2,141 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,922 developers. It's quick & easy.

empty recycle bin with c#

Hi,

I wrote some code using the shell32.dll to query the size of the
recycle bin. The function does not produce an error but the results
are not correct:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct SHQUERYRBINFO
{
public Int32 cbSize;
public UInt64 i64Size;
public UInt64 i64NumItems;
}

[DllImport("shell32.dll" , CharSet = CharSet.Unicode)]
public static extern int SHQueryRecycleBin(
[MarshalAs(UnmanagedType.LPTStr)]
String pszRootPath,
ref SHQUERYRBINFO pSHQueryRBInfo
);

SHQUERYRBINFO bb_query = new SHQUERYRBINFO();
bb_query.cbSize = Marshal.SizeOf(bb_query.GetType());
iRetVal = (int)SHQueryRecycleBin(BitBucket_Path, ref bb_query);
iRetVal is 0, but:

* if there are elements in the recycle bin the size is always
4294967296 and the number of elements is 0

* if the recycle bin is empty the size is 0 and the number of elements
is 0 (this is correct)

Any hints what's wrong? Are there other shell32 functions to query
single objects in the bin?

Thanks for your help,

Thomas
Nov 15 '05 #1
1 2563
Thomas,

Add Pack=1 to the StructLayout attribute on SHQUERYRBINFO.

Mattias

--
Mattias Sjgren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kerem Gmrkc | last post: by
5 posts views Thread by Gene Vital | last post: by
2 posts views Thread by John | last post: by
5 posts views Thread by johnb41 | last post: by
2 posts views Thread by vighnesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.