11-24-2010 12:21 PM
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?
11-24-2010 04:25 PM - edited 11-24-2010 04:27 PM
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.
11-27-2010 02:35 AM
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.
11-27-2010 02:41 AM
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
12-01-2010 11:02 AM
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?
12-01-2010 11:37 AM
12-01-2010 12:25 PM
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.
12-01-2010 12:52 PM - edited 12-01-2010 01:01 PM
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");
}
12-01-2010 01:10 PM
To make sure you understood Roberto's earlier note, you need to add Shell32.lib to your project, not Shell32.dll.
12-01-2010 01:29 PM
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.