Write to a file from Windows Explorer extension with UAC dialog - c++

I need to copy a virtual file from my Windows Explorer namespace extension to a restricted location (for example to C:). Normally for such task one need to run a new process elevated that should do the operation.
However in this case I'm running in explorer.exe process context, and I need to get the same "You'll need to provide administrator permission to copy..." dialog that Windows Explorer presents, rather than a UAC dialog for a new process.
Anyone knows what function Windows Explorer uses to achieve this? ShFileOperation does what I need, but seems to work only for file system objects. How Windows Explorer copies files from zip archives which are represented via namespsace extensions too? Thank you

Related

Directory watcher for file open

I am using ReadDirectoryChanges (for windows) and FSEventStreamCreate (for macosx) to watch for activities in a particular directory.
Unfortunately they both seem to be limited to reporting for events that modify in one or another way the content in the directory.
Is there any API (documented or not), tricks or whatever way that I can use to detect open for read access to a file in a directory.
P.S. My priority is windows and mac, but if you know how to do it in linux please feel free to share it.

Winlicense with hardware lock of Windows exe

I have a Windows exe file, which I want to make hardware-locked. I want it to run only on computers, which have a valid license key. For this I use Winlicense.
I created a project in Winlicense and all is OK, but when I click "Protect" the protection finishes successfully, but the exe is running without any problems on any Windows computer. I expect to see a message that this program requires a valid key in order to run.
I can send the XML of my Winlicense project together with the exe file (the exe file is absolutely empty).
What is the right way to protect the exe, so that it asks for a valid key when it is run?

Create directories anywhere in windows 7?

I have an application that requires that a DLL be able to create various directories in it's current location. However, from looking around, I have found that windows 7 apparently restricts the ability of programs to write in a lot of places. I cannot redesign the application, as the DLL is injected into a process and creates log files that the user would view. I don't want to shove them in appdata, is there any other way to do what I want?
You can try to change the current working directory with SetCurrentDirectory

DLL registering and Unregistering

I have created a context menu dll (C++ COM DLL) to show iconoverlays (using IShellIconOverlayIdentifier interface). To show the iconoverlays initially I have restarted the explorer. If the system restarts, to display the icon overlays, I need to manually register the dll and restart the explorer once again.
Is there any way to register my com dll before explorer starts. ??
Also, if I uninstall my application the DLL can not be removed. To remove the dll, I need to stop the explorer and other applications (For eg, thunderbird, visual studio) which use my dll, then unregister the dll. Then only I am able to delete the Dll. Is this correct.. Or any thing else I can do.
Thanks in Advance.
I wonder why you have to register your DLL on every restart of your system.
On the other hand it is quite normal that you have to restart explorer.exe and related programs to let the changes - especially done by shell extensions - take effect.
Further, the beahivour you encounter upon deletion is the standard procedure one has to go through when you want to delete your shell extension DLL.
You may want to use self-registrating DLLs. They include information required to store themselves in the operating system's registry and will automatically store themselves on your machine and become accessible when needed.
A detailed explanation can be found here : Self-Registration (COM)

How To Disable Shell Extension In FileOpen Dialog

I am talking about windows shell extensions.
I have a shell extension which could show the specific properties of my customized file type, say, *.filetype. And of course it will cause my shell extension dlls being loaded into the explorer.exe process. But now if I fire the FileOpen dialog in any application and check the file properties inside that dialog(notepad as an example), then these shell extension dlls would be loaded into notepad.exe process, which is the case I want to avoid.
So is it possible to disable a specific shell extension in FileOpen Dialog?
Thanks.
Create a shim dll which does nothing but load your real (big) shell extension dll.
The only job of that shim dll is to check whether the current process is "explorer.exe". If it is, the shim loads the real dll and forwards all calls there. If it's not, the shim doesn't load your real dll but simply returns E_NOTIMPL or something like that to all requests.