shell32

Using SHFileOperation within a Windows service

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 12:01:57
问题 It's possible, but is it appropriate to use SHFileOperation within a Windows service? All those SHxxx API functions in shell32.dll seem to have been written with user level programs in mind. Can I be certain SHFileOperation won't display GUI ever? 回答1: I would say, not it's not appropriate or advisable. Most of the shell32 APIs were written with a basic understanding that they would be used in interactive processes. I don't think there is any way you can guarantee that SHFileOperation will

Use SHAssocEnumHandlers in C#

折月煮酒 提交于 2019-12-02 06:06:56
I am struggling to call the WinAPI SHAssocEnumHandlers in C#. using System; using System.Runtime.InteropServices; namespace AssocHandlerTest { [Flags] public enum ASSOC_FILTER { ASSOC_FILTER_NONE = 0x0, ASSOC_FILTER_RECOMMENDED = 0x1 }; [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("F04061AC-1659-4a3f-A954-775AA57FC083")] public interface IAssocHandler { int GetName([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppsz); int GetUIName([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppsz); int GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] out string

Calling Shell32.dll from .NET Windows Service

百般思念 提交于 2019-12-01 03:23:51
I have a .NET 4.0 library that uses Shell32 and Folder.GetDetailsOf() to get metadata from WTV files. I have used it successfully with Console and Windows Forms apps without issue. But for some reason, when calling the component from a .NET 4.0 Windows Service, the call to initiate the Shell class causes a COM error. The code that fails inside the library: Shell32.Shell shell = new Shell(); The error: Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'. This operation failed because the QueryInterface call on the COM component for the interface with IID '

Get CSIDL_LOCAL_APPDATA path for any user on Windows

我与影子孤独终老i 提交于 2019-11-30 09:28:12
问题 Is there any Win32/MFC API to get the CSIDL_LOCAL_APPDATA for any user that I want (not only the currently logged on one)? Let's say I have a list of users in the form "domain\user" and I want to get a list of their paths - is that possible? 回答1: You can get the SID for the user and then look it up under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and get the ProfileImagePath value. Once you have this path, you can get CLSID_LOCAL_APPDATA for your user, convert the absolute

Get CSIDL_LOCAL_APPDATA path for any user on Windows

余生长醉 提交于 2019-11-29 15:14:40
Is there any Win32/MFC API to get the CSIDL_LOCAL_APPDATA for any user that I want (not only the currently logged on one)? Let's say I have a list of users in the form "domain\user" and I want to get a list of their paths - is that possible? You can get the SID for the user and then look it up under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and get the ProfileImagePath value. Once you have this path, you can get CLSID_LOCAL_APPDATA for your user, convert the absolute path to a relative path to your profile and then append that relative path to the other user profile path.

Why do i get E_ACCESSDENIED when reading public shortcuts through Shell32?

笑着哭i 提交于 2019-11-29 14:29:52
I'm trying to read the targets of all desktop shortcuts in a C# 4 application. The shortcuts on a windows desktop can come from more that one location, depending on whether the shortcut is created for all users or just the current user. In this specific case I'm trying to read a shortcut from the public desktop, e.g. from C:\Users\Public\Desktop\shortcut.lnk. The code is like this (path is a string contaning the path to the lnk file): var shell = new Shell32.ShellClass(); var folder = shell.NameSpace(Path.GetDirectoryName(path)); var folderItem = folder.ParseName(Path.GetFileName(path)); if

What options are available for Shell32.Folder.GetDetailsOf(..,..)?

萝らか妹 提交于 2019-11-28 04:31:07
问题 I've seen answers using GetDetailsOf() to get details about shell items, but the numbers are always magic numbers. I've looked at the docs for both FolderItem and GetDetailsOf but found nothing. (The list in the latter is not for everything. They don't cover "Description", "Authors", nor the recycle bin delete date...) Is there some method that will return the possible options for an item? Is it listed somewhere? 回答1: I figured this out by accident. If you pass null into GetDetailsOf then it

How to use Shell32 within a C# application?

扶醉桌前 提交于 2019-11-26 06:39:23
问题 What should I include within a C# application in order to make Shell32 work? Edit: My application can\'t recognize shell32. What references or lib should I include? What I\'m trying to do is: Shell32.Shell shell = new Shell32.Shell(); What I\'m getting as an error: Error 1 The type or namespace name \'Shell32\' could not be found (are you missing a using directive or an assembly reference?) 回答1: Just add a reference to Shell32.dll from the Windows\System32 folder and use it: Shell32.Shell