win32api restore file from recyclebin using SHFileStruct - winapi

I'm using win 32 api to built explore is the same window.
I can delete file to recycle bin. Now, I want to undo files which were deleted to recycle bin.
What am I doing now?
please help me.

This article on CodeProject seems to be what you are looking for.

You have to retrieve the IContextMenu interface for the desired file in the Recycle Bin folder, and then you can use the IContextMenu::InvokeCommand() method to invoke verbs on the file. See MSDN for more details:
Invoking commands on items in the Recycle Bin

Related

Copy files from VSS

I am working on a windows VSS application, I want some help regarding it.
After creating snapshot, how can I copy the files or files' blocks(sectors), preferably files' blocks, from volume snapshot using C/C++. Can someone guide me on this or can direct me to any samples or documentation doing the same.
Thanks in advance.
You can access VSS snapshot items using regular functions
CreateFile() to open a file
ReadFile() or BackupRead() to read/backup its data
Only the root path to the items will change
(for example, \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopyX\ instead of C:\ )
What do you want to know exactly?

Hiding Files in Windows

Currently, I'm developing a system which will extract some files from an SFX archive (files that will be used for another app). I want to make the extracted files hidden, so the person which has find the location of the exe couldn't get the files which will be in same directory with the exe. I know i can apply attrib +h to the files but if the user turns on "show hidden and system files" option in Windows, the files will be visible.
Isn't there any method to overcome this? Any suggestion is welcomed.
Thanks.
If you're writing to the disk, a user can find and read your file. There's no way around that, one could monitor what happens when your application is run, find what files it's writing to, or just intercept while it's being written. Consider why you don't want the user to find your files.
Is it because there's sensitive data, or things you'd rather they didn't change? Consider encrypting it, or verifying it's integrity with a checksum or hash.
Guess you could play around with user rights. However, you'd need to ask an administrator right at install then to make it hidden from the given user who is an admin on the PC.

Delete files from disk that aren't in a Visual Studio project

Can anyone think of a way (perhaps using a PowerShell script or similar) where I can look for *.cs files that are on disk in the folder structure, but aren't included in a project file?
This has come about gradually over time with merging in Subversion etc. I'm looking for a way to clean up after myself, basically. :)
All your .cs files will be mentioned in the project file, right? Scrape the XML, list the files and then do a search on the whole system. Works, but is inefficient.
"Show all files" button at the top of Solution Explorer, then manually inspect?
The PowerShell script in my other post will do this. The script will get the list of included files from the project file and compare that against the files on disk. You will get the set of files that are on disk but not included in the project. You can either delete them or pend them as deletes in TFS.
The script is here: https://stackoverflow.com/a/23420956/846428

Command-line tool for finding out who is locking a file

I would like to know who is locking a file (win32). I know about WhoLockMe, but I would like a command-line tool which does more or less the same thing.
I also looked at this question, but it seems only applicable for files opened remotely.
Handle should do the trick.
Ever wondered which program has a particular file or directory open?
Now you can find out. Handle is a utility that displays information
about open handles for any process in the system. You can use it to
see the programs that have a file open, or to see the object types and
names of all the handles of a program.
handle.exe
http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
THis has helped me sooooo many times....
Download Handle.
https://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
If you want to find what program has a handle on a certain file, run this from the directory that Handle.exe is extracted to. Unless you've added Handle.exe to the PATH environment variable. And the file path is C:\path\path\file.txt", run this:
handle "C:\path\path\file.txt"
This will tell you what process(es) have the file (or folder) locked.
In my case Handle.exe did not help.
Simple program from official Microsoft called Process Explorer was useful.
Just open as administrator and press Ctrl+f, type part of file name it will show process using file.
Handle didn't find that WhatsApp is holding lock on a file .tmp.node in temp folder.
ProcessExplorer - Find works better
Look at this answer https://superuser.com/a/399660
Computer Management->Shared Folders->Open Files
I have used Unlocker for years and really like it. It not only will identify programs and offer to unlock the folder\file, it will allow you to kill the processing that has the lock as well.
Additionally, it offers actions to do to the locked file in question such as deleting it.
Unlocker helps delete locked files with error messages including "cannot delete file," and "access is denied." Video tutorial available.
Some errors you might get that Unlocker can help with include:
Cannot delete file: Access is denied.
There has been a sharing violation.
The source or destination file may be in use.
The file is in use by another program or user.
Make sure the disk is not full or write-protected and that the file is not currently in use.

How to change directory security attributes using InstallShield?

I'd like to change the security attribute of a directory that InstallShield creates under the CSIDL_COMMON_APPDATA - can someone please advise on how to do that during the installation process?
It's a script-defined folder.
Thank you.
Under InstallShield 2008 it's
Installation Designer > Components > [somecomponent] > Destination Permissions
Note that the directory properties are attached to the component, while individual File permissions are set under the 'Files' node
This assumes you are letting InstallShield / Windows Installer handle directory creation. If you're creating the directory in a script then things start getting tricky if you need to ensure a clean uninstall.
I think I found the answer for this - on this page: http://www.installsite.org/pages/en/isp_os.htm there's an ntperm.zip archive which contains a script that seems to do what I need.
you can also just easily call Windows commands "CACLS.EXE" or "ICACLS.EXE" -both are easy command line tool, e.g.
icacls file /grant Administrator:(D,WDAC)
- Will grant the user Administrator Delete and Write DAC
permissions to file
I don't know whether a Installshield builtin function exists for that. The simple solution is to create a DLL that does the real work of manipulating the security attributes and call it once the directory is created.
Typically, one might want to change the access so that everyone is able to read/write to the whole directory or file(s) within it.

Resources