Sign in to follow this  
Followers 0
rasim

Get the size of recycle bin

10 posts in this topic

I trying to get the number of files in recycle bin and the size of recycle bin, but unsuccessful :)

Global $SHQUERYRBINFO = DllStructCreate("int;int64;int64")

DllStructSetData($SHQUERYRBINFO, 1, DllStructGetSize($SHQUERYRBINFO))

$Query = DllCall("shell32.dll", "int", "SHQueryRecycleBin", "str", "C:\", "ptr", DllStructGetPtr($SHQUERYRBINFO))

ConsoleWrite("DllCall return value is: " & $Query[0] & @LF)

ConsoleWrite(DllStructGetData($SHQUERYRBINFO, 1) & @LF & _
             DllStructGetData($SHQUERYRBINFO, 2) & @LF & _ ; size of recycle bin in bytes
             DllStructGetData($SHQUERYRBINFO, 3) & @LF)    ; number of items in recycle bin

Help from MSDN

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I tested your call, It works

try unicode

$Query = DllCall("shell32.dll", "int", "SHQueryRecycleBinW", "wstr", "C:\", "ptr", DllStructGetPtr($SHQUERYRBINFO))

DllCall return value is: 0
20          ; what is this value?
4865186     ; size of files
46          ; # of files in my Recycle Bin
>Exit code: 0    Time: 0.437
Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

Thanks, but still not work correctly:

DllCall return value is: 0
24
21474836480 ; Size of files (really is 52 MB)
0                  ; # of files in my Recycle Bin (really is 5)

:)

OS:WinXP (SP2), Langue (Russian)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks, but still not work correctly:

DllCall return value is: 0
24
21474836480 ; Size of files (really is 52 MB)
0                  ; # of files in my Recycle Bin (really is 5)

:)

OS:WinXP (SP2), Langue (Russian)

When you are counting files in the RB there are two in there that do not show up when you open it. So when you do get a count it will probably be out by 2.

EDIT: No, I was wrong Those files do not show up. BTW, I don't know what that 24 is but it shows the same result for an empty recycle bin as it does for a full one.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I see according to the MSDN page for SHQUERYRBINFO Structure

that the parameter "cbSize" is the size of the struct.

I get 20, you get 24 for the same call.

The unicode version works for me as does Ansi

http://msdn2.microsoft.com/en-us/library/b...803(VS.85).aspx

Edit: O.K. This call works in v3.2.8.1 but NOT in v3.2.10.0 and v3.2.11.3

machine with both 3.2.8.1 and beta 3.2.11.3

(need to download and try latest beta 3.2.11.4)

v3.2.11.3 - Invalid return

DllCall return value is: 0

24

197568495616

0

>Exit code: 0 Time: 0.469

v3.2.8.1 - Valid return

DllCall return value is: 0

20

4865186 ; size of files

46 ; # of files in my Recycle Bin

>Exit code: 0

I just tried this on another machine (both are XP EN SP2 X86)

I get what you get:

I have 100meg approx. in recycle bin

v3.2.10.0 - Invalid return

DllCall return value is: 0

24 ; same return of 24 instead of 20

0

0

Exit code: 0

I need to see what services I have turned off on that machine

one thing is the machine it works on has been updated recently

the other machine is on Lan but not allowed online and updates are older.

we know this works, perhaps it's an issue with the struct parameters?

Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

this changed struct works in v3.2.11.3

;Global $SHQUERYRBINFO = DllStructCreate("int;int64;int64") ; v3.2.8.1
Global $SHQUERYRBINFO = DllStructCreate("align 1;int;int64;int64") ; v3.2.11.3

DllStructSetData($SHQUERYRBINFO, 1, DllStructGetSize($SHQUERYRBINFO))

$Query = DllCall("shell32.dll", "int", "SHQueryRecycleBin", "str", "C:\", "ptr", DllStructGetPtr($SHQUERYRBINFO))

ConsoleWrite("DllCall return value is: " & $Query[0] & @LF)

ConsoleWrite(DllStructGetData($SHQUERYRBINFO, 1) & @LF & _ ; "cbSize" size of the struct = 20
             DllStructGetData($SHQUERYRBINFO, 2) & @LF & _ ; size of recycle bin in bytes
             DllStructGetData($SHQUERYRBINFO, 3) & @LF)    ; number of items in recycle bin

I see fascists...

Share this post


Link to post
Share on other sites

rover

we know this works, perhaps it's an issue with the struct parameters?

Mayb...

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

this changed struct works in v3.2.11.3

;Global $SHQUERYRBINFO = DllStructCreate("int;int64;int64") ; v3.2.8.1
Global $SHQUERYRBINFO = DllStructCreate("align 1;int;int64;int64") ; v3.2.11.3

DllStructSetData($SHQUERYRBINFO, 1, DllStructGetSize($SHQUERYRBINFO))

$Query = DllCall("shell32.dll", "int", "SHQueryRecycleBin", "str", "C:\", "ptr", DllStructGetPtr($SHQUERYRBINFO))

ConsoleWrite("DllCall return value is: " & $Query[0] & @LF)

ConsoleWrite(DllStructGetData($SHQUERYRBINFO, 1) & @LF & _ ; "cbSize" size of the struct = 20
             DllStructGetData($SHQUERYRBINFO, 2) & @LF & _ ; size of recycle bin in bytes
             DllStructGetData($SHQUERYRBINFO, 3) & @LF)    ; number of items in recycle bin
Yes! :) Now it`s work correct! Thank you! :) But where you find this DllStructCreate("align 1;int;int64;int64")?

Edit: Tested on version 3.2.10.0 :party:

Edited by rasim

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Yes! :) Now it`s work correct! Thank you! :) But where you find this DllStructCreate("align 1;int;int64;int64")?

Edit: Tested on version 3.2.10.0 :party:

from reading the helpfile (v3.2.11.3) :lmao:

The first thing I noticed was your posted result of 24 for the struct size

my code returned 20 in v3.2.8.1

I saw the changes to DllStructCreate()

from 3.2.8.1 (see section on 'structure alignment' in 'Remarks').

seeing as nothing else was wrong, i.e. no changes made to accommodate 64bit

support were a problem here. (in regards to DllCall)

It was an inspired guess..

however I tried this on my other machine with v3.2.10.0 and it doesn't work.

so I compiled in v3.2.11.3 and tried that on it.

still no go

compiled on that problem machine in v3.2.10.0 and transfered to other machine works fine.

so, therefore there is also something in XP that can prevent this from working.

I need to look at that other XP machine and see if I can find out what keeps that dllcall from working.

It is the machine thats not currently updated (has no online access, but is SP2+)

perhaps a service I have turned off.

Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

rover

from reading the helpfile

Damn! :) I are unattentive. Help rulez! :) Thank you! Posted Image

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0