LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to delete all files in RECYCLER.

Don't want give all disks, a directories, search all files here and delete their. I want get a API command "Empty RECYCLER.". How i do that?

0 Kudos
Message 1 of 11
(4,273 Views)

There actually is SHEmptyRecycleBin Win API that should do what you want. I have never used it but according to the documentation it should be quite easy to call from CVI environment.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 11
(4,262 Views)

Have a problem with include "shell32.dll" into project. In other posts writed: "tools menu -> imropt -> ...", but i don't see this item. Give me a path to include shell32.dll, please.

0 Kudos
Message 3 of 11
(4,229 Views)

Sergey,

as you see in MSDN documentation I linked, you must include shell32.lib in the project! You can include it this way:

 

Edit >> Add files to project >> Library menu function

Navigate to the SDK libraries path (e.g. <cvidir>\sdk\lib\msvc )

Select and load shell32.lib



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 11
(4,225 Views)

Edit >> Add files to project >> Library menu function

Navigate to the SDK libraries path (e.g. <cvidir>\sdk\lib\msvc )

Select and load shell32.lib

 

Loaded, but function SHEmptyRecycleBin - error "Missing Prototipe".

 

Unloaded .lib and writed #include <Shellapi.h>. File compiled successfully. But in build debug-exe-file returned error in attach. What wrong?

Download All
0 Kudos
Message 5 of 11
(4,176 Views)
You might need something like: #define WINVER 0x0500 before your #include "Shellapi.h" statement. JR
0 Kudos
Message 6 of 11
(4,160 Views)

That not work:

 

#define SHERB_NOCONFIRMATION    0x00000001
#define SHERB_NOPROGRESSUI      0x00000002
#define SHERB_NOSOUND           0x00000004

#include <windows.h>
#include <cvintwrk.h>
#include "inifile.h"
#include <formatio.h>
#include <ansi_c.h>
#include <utility.h>
#include <cvirte.h>  
#include <userint.h>
#include "variables.h"
#include "garbage_collector.h"
#include <Shellapi.h>

 

Strings getted in Shellapi.h.

0 Kudos
Message 7 of 11
(4,150 Views)

Sergey:

 

Try the attached example.  Roberto has already laid it out for you.  You need to add shell32.lib to your project, #include windows.h and shellapi.h in your .c file, and call SHEmptyRecycleBin().

 

From your previous posts, it sounds like you already have the Windows SDK/Win32 API installed, but if this wasn't done correctly or completely, you'll have problems.  Also make sure that you're using the SDK that came with CVI and not one that came with some other product like Visual Studio.

 

Here's all the code, but I also included the .c and .prj files to make it easier.

 

#include <windows.h>
#include <userint.h>
#include <shellapi.h>

main()
{
 HRESULT emptyResult;
 
 emptyResult = SHEmptyRecycleBin(NULL, NULL, 0);
 
 if (emptyResult != S_OK)
  MessagePopup ("Recycle Bin Error", "Error emptying recycle bin");
  
}

Download All
0 Kudos
Message 8 of 11
(4,131 Views)

To make sure you understood Roberto's earlier note, you need to add Shell32.lib to your project, not Shell32.dll.

0 Kudos
Message 9 of 11
(4,113 Views)

Solution in 3 parts.

 

1. Add Shell32.Lib into project.

 

2. #include <Shellapi.h>.

 

3. Call SHEmptyRecycleBinA(0,NULL,1);

Parameters:

SHERB_NOCONFIRMATION

No dialog box confirming the deletion of the objects will be displayed.

SHERB_NOPROGRESSUI

No dialog box indicating the progress will be displayed.

SHERB_NOSOUND

No sound will be played when the operation is complete.

 

0 Kudos
Message 10 of 11
(4,111 Views)