Skip to content

Commit 71afbb3

Browse files
committed
Init
1 parent a6b39a9 commit 71afbb3

File tree

14 files changed

+532
-272
lines changed

14 files changed

+532
-272
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.InteropServices;
7+
using Windows.Win32.Foundation;
8+
using Windows.Win32.UI.Shell;
9+
10+
namespace Windows.Win32.System.Com
11+
{
12+
/// <summary>
13+
/// Defines unmanaged raw vtable for the <see cref="IAutomaticDestinationList"/> interface.
14+
/// </summary>
15+
public unsafe partial struct IAutomaticDestinationList : IComIID
16+
{
17+
#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
18+
private void** lpVtbl;
19+
#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
20+
21+
/// <summary>
22+
/// Initializes this instance of <see cref="IAutomaticDestinationList"/> with the specified Application User Model ID (AMUID).
23+
/// </summary>
24+
/// <param name="szAppId">The Application User Model ID to initialize this instance of <see cref="IAutomaticDestinationList"/> with.</param>
25+
/// <param name="a2">Unknown argument. Apparently this can be NULL.</param>
26+
/// <param name="a3">Unknown argument. Apparently this can be NULL.</param>
27+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
28+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
29+
public HRESULT Initialize(PCWSTR szAppId, PCWSTR a2, PCWSTR a3)
30+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, PCWSTR, PCWSTR, PCWSTR, int>)lpVtbl[3])
31+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), szAppId, a2, a3);
32+
33+
/// <summary>
34+
/// Gets a value that determines whether this <see cref="IAutomaticDestinationList"/> has any list.
35+
/// </summary>
36+
/// <param name="pfHasList">A pointer to a <see cref="BOOL"/> that receives the result. <see cref="BOOL.TRUE"/> if there's any list; otherwise, <see cref="BOOL.FALSE"/>.</param>
37+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
38+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
39+
public HRESULT HasList(BOOL* pfHasList)
40+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, BOOL*, int>)lpVtbl[4])
41+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), pfHasList);
42+
43+
/// <summary>
44+
/// Gets the list of automatic destinations of the specified type.
45+
/// </summary>
46+
/// <param name="type">The type to get the automatic destinations of.</param>
47+
/// <param name="maxCount">The max count to get the automatic destinations up to.</param>
48+
/// <param name="flags">The flags to filter up the queried destinations.</param>
49+
/// <param name="riid">A reference to the interface identifier (IID) of the interface being queried for.</param>
50+
/// <param name="ppvObject">The address of a pointer to an interface with the IID specified in the riid parameter.</param>
51+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
52+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
53+
public HRESULT GetList(DESTLISTTYPE type, int maxCount, GETDESTLISTFLAGS flags, Guid* riid, void** ppvObject)
54+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, DESTLISTTYPE, int, GETDESTLISTFLAGS, Guid*, void**, int>)lpVtbl[5])
55+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), type, maxCount, flags, riid, ppvObject);
56+
57+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
58+
public HRESULT AddUsagePoint(IUnknown* pUnk)
59+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, int>)lpVtbl[6])
60+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), pUnk);
61+
62+
/// <summary>
63+
/// Pins an item to the list.
64+
/// </summary>
65+
/// <param name="pUnk">The native object to pin to the list.</param>
66+
/// <param name="index">-1 to pin to the last, -2 to unpin, zero or positive numbers (>= 0) indicate the index to pin to the list at. Passing the other numbers are *UB*.</param>
67+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
68+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
69+
public HRESULT PinItem(IUnknown* pUnk, int index)
70+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, int, int>)lpVtbl[7])
71+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), pUnk, index);
72+
73+
/// <summary>
74+
/// Gets the index of a pinned item in the Pinned list.
75+
/// </summary>
76+
/// <remarks>
77+
/// According to the debug symbols, this method is called "IsPinned" and other definitions out there also define so
78+
/// but it is inappropriate based on the fact it actually calls an internal method that gets the index of a pinned item
79+
/// and returns it in the second argument. If you want to check if an item is pinned, you should use IShellItem::Compare for IShellItem,
80+
/// or compare IShellLinkW::GetPath, IShellLinkW::GetArguments and PKEY_Title for IShellLinkW, which is actually done, at least, in Windows 7 era.
81+
/// </remarks>
82+
/// <param name="punk">The native object to get its index in the list.</param>
83+
/// <param name="piIndex">A pointer that points to an int value that takes the index of the item passed.</param>
84+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise. If the passed item doesn't belong to the <see cref="DESTLISTTYPE.PINNED"/> list, HRESULT.E_NOT_SET is returned.</returns>
85+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
86+
public HRESULT GetPinIndex(IUnknown* punk, int* piIndex)
87+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, int*, int>)lpVtbl[8])
88+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), punk, piIndex);
89+
90+
/// <summary>
91+
/// Removes a destination from the automatic destinations list.
92+
/// </summary>
93+
/// <param name="psi">The destination to remove from the automatic destinations list.</param>
94+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.
95+
public HRESULT RemoveDestination(IUnknown* psi)
96+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, int>)lpVtbl[9])
97+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), psi);
98+
99+
public HRESULT SetUsageData(IUnknown* pItem, float* a2, long* pFileTime)
100+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, float*, long*, int>)lpVtbl[10])
101+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), pItem, a2, pFileTime);
102+
103+
public HRESULT GetUsageData(IUnknown* pItem, float* a2, long* pFileTime)
104+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, IUnknown*, float*, long*, int>)lpVtbl[11])
105+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), pItem, a2, pFileTime);
106+
107+
public HRESULT ResolveDestination(HWND hWnd, int a2, IShellItem* pShellItem, Guid* riid, void** ppvObject)
108+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, HWND, int, IShellItem*, Guid*, void**, int>)lpVtbl[12])
109+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), hWnd, a2, pShellItem, riid, ppvObject);
110+
111+
public HRESULT ClearList(BOOL clearPinsToo)
112+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IAutomaticDestinationList*, BOOL, int>)lpVtbl[13])
113+
((IAutomaticDestinationList*)Unsafe.AsPointer(ref this), clearPinsToo);
114+
115+
[GuidRVAGen.Guid("E9C5EF8D-FD41-4F72-BA87-EB03BAD5817C")]
116+
public static partial ref readonly Guid Guid { get; }
117+
118+
internal static ref readonly Guid IID_Guid
119+
=> ref MemoryMarshal.AsRef<Guid>([0xBF, 0xDE, 0x32, 0x63, 0xB5, 0x87, 0x70, 0x46, 0x90, 0xC0, 0x5E, 0x57, 0xB4, 0x08, 0xA4, 0x9E]);
120+
121+
internal static Guid* IID_Guid2
122+
=> (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IID_Guid));
123+
124+
static ref readonly Guid IComIID.Guid => ref IID_Guid;
125+
}
126+
127+
public enum DESTLISTTYPE : uint
128+
{
129+
PINNED,
130+
RECENT,
131+
FREQUENT,
132+
}
133+
134+
public enum GETDESTLISTFLAGS : uint
135+
{
136+
NONE,
137+
EXCLUDE_UNNAMED_DESTINATIONS,
138+
}
139+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copyright (c) 0x5BFA. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.InteropServices;
7+
using Windows.Win32.Foundation;
8+
using Windows.Win32.UI.Shell;
9+
10+
namespace Windows.Win32.System.Com
11+
{
12+
/// <summary>
13+
/// Defines unmanaged raw vtable for the <see cref="IInternalCustomDestinationList"/> interface.
14+
/// </summary>
15+
/// <remarks>
16+
/// - <a href="https://github.com/GigabyteProductions/classicshell/blob/HEAD/src/ClassicStartMenu/ClassicStartMenuDLL/JumpLists.cpp"/>
17+
/// </remarks>
18+
public unsafe partial struct IInternalCustomDestinationList : IComIID
19+
{
20+
#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
21+
private void** lpVtbl;
22+
#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value'
23+
24+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
25+
public HRESULT SetMinItems(uint dwMinItems)
26+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, uint, int>)lpVtbl[3])(
27+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), dwMinItems);
28+
29+
/// <summary>
30+
/// Initializes this instance of <see cref="IInternalCustomDestinationList"/> with the specified Application User Model ID (AMUID).
31+
/// </summary>
32+
/// <param name="pszAppID">The Application User Model ID to initialize this instance of <see cref="IInternalCustomDestinationList"/> with.</param>
33+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
34+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
35+
public HRESULT SetApplicationID(PCWSTR pszAppID)
36+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, PCWSTR, int>)lpVtbl[4])(
37+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), pszAppID);
38+
39+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
40+
public HRESULT GetSlotCount(uint* pSlotCount)
41+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, uint*, int>)lpVtbl[5])(
42+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), pSlotCount);
43+
44+
/// <summary>
45+
/// Gets the number of categories in the custom destination list.
46+
/// </summary>
47+
/// <param name="pdwCategoryCount">A pointer that points to a valid <see langword="uint"/> var.</param>
48+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
49+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
50+
public HRESULT GetCategoryCount(uint* pCategoryCount)
51+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, uint*, int>)lpVtbl[6])(
52+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), pCategoryCount);
53+
54+
/// <summary>
55+
/// Gets the category at the specified index in the custom destination list.
56+
/// </summary>
57+
/// <param name="index">The index to get the category in the custom destination list at.</param>
58+
/// <param name="flags">The flags to filter up the queried destinations.</param>
59+
/// <param name="pCategory">A pointer that points to a valid <see cref="APPDESTCATEGORY"/> var.</param>
60+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
61+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
62+
public HRESULT GetCategory(uint index, GETCATFLAG flags, APPDESTCATEGORY* pCategory)
63+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, uint, GETCATFLAG, APPDESTCATEGORY*, int>)lpVtbl[7])(
64+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), index, flags, pCategory);
65+
66+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
67+
public HRESULT DeleteCategory(uint index, BOOL deletePermanently)
68+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, uint, BOOL, int>)lpVtbl[8])(
69+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), index, deletePermanently);
70+
71+
/// <summary>
72+
/// Enumerates the destinations at the specific index in the categories in the custom destinations.
73+
/// </summary>
74+
/// <param name="index">The index to get the destinations at in the categories.</param>
75+
/// <param name="riid">A reference to the interface identifier (IID) of the interface being queried for.</param>
76+
/// <param name="ppvObject">The address of a pointer to an interface with the IID specified in the riid parameter.</param>
77+
/// <returns>Returns <see cref="HRESULT.S_OK"/> if successful, or an error value otherwise.</returns>
78+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
79+
public HRESULT EnumerateCategoryDestinations(uint index, Guid* riid, void** ppvObject)
80+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, uint, Guid*, void**, int>)lpVtbl[9])(
81+
(IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), index, riid, ppvObject);
82+
83+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
84+
public HRESULT RemoveDestination(IUnknown* pUnk)
85+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, IUnknown*, int>)lpVtbl[10])
86+
((IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), pUnk);
87+
88+
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
89+
//public HRESULT ResolveDestination(...)
90+
// => (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, ..., int>)lpVtbl[11])
91+
// ((IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), ...);
92+
93+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
94+
public HRESULT HasListEx(int* a1, int* a2)
95+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, int*, int*, int>)lpVtbl[12])
96+
((IInternalCustomDestinationList*)Unsafe.AsPointer(ref this), a1, a2);
97+
98+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
99+
public HRESULT ClearRemovedDestinations()
100+
=> (HRESULT)((delegate* unmanaged[MemberFunction]<IInternalCustomDestinationList*, int>)lpVtbl[13])
101+
((IInternalCustomDestinationList*)Unsafe.AsPointer(ref this));
102+
103+
static ref readonly Guid IComIID.Guid => throw new NotImplementedException();
104+
}
105+
106+
[StructLayout(LayoutKind.Sequential)]
107+
public unsafe struct APPDESTCATEGORY
108+
{
109+
[StructLayout(LayoutKind.Explicit)]
110+
public struct _Anonymous_e__Union
111+
{
112+
[FieldOffset(0)]
113+
public PWSTR Name;
114+
115+
[FieldOffset(0)]
116+
public int SubType;
117+
}
118+
119+
public APPDESTCATEGORYTYPE Type;
120+
121+
public _Anonymous_e__Union Anonymous;
122+
123+
public int Count;
124+
125+
public fixed int Padding[10];
126+
}
127+
128+
public enum GETCATFLAG : uint
129+
{
130+
// 1 is the only valid value?
131+
DEFAULT = 1,
132+
}
133+
134+
public enum APPDESTCATEGORYTYPE : uint
135+
{
136+
CUSTOM = 0,
137+
KNOWN = 1,
138+
TASKS = 2,
139+
}
140+
}

src/Files.App.CsWin32/ManualGuid.cs renamed to src/Files.App.CsWin32/ManualGuids.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ public static unsafe partial class IID
1212
public static Guid* IID_IStorageProviderStatusUISourceFactory
1313
=> (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IStorageProviderStatusUISourceFactory.Guid));
1414

15+
[GuidRVAGen.Guid("E9C5EF8D-FD41-4F72-BA87-EB03BAD5817C")]
16+
public static partial Guid* IID_IAutomaticDestinationList { get; }
17+
18+
[GuidRVAGen.Guid("6332DEBF-87B5-4670-90C0-5E57B408A49E")]
19+
public static partial Guid* IID_ICustomDestinationList { get; }
20+
21+
[GuidRVAGen.Guid("5632B1A4-E38A-400A-928A-D4CD63230295")]
22+
public static partial Guid* IID_IObjectCollection { get; }
23+
24+
[GuidRVAGen.Guid("00000000-0000-0000-C000-000000000046")]
25+
public static partial Guid* IID_IUnknown { get; }
26+
27+
[GuidRVAGen.Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99")]
28+
public static partial Guid* IID_IPropertyStore { get; }
29+
30+
[GuidRVAGen.Guid("507101CD-F6AD-46C8-8E20-EEB9E6BAC47F")]
31+
public static partial Guid* IID_IInternalCustomDestinationList { get; }
32+
1533
[GuidRVAGen.Guid("000214E4-0000-0000-C000-000000000046")]
1634
public static partial Guid* IID_IContextMenu { get; }
1735

@@ -66,6 +84,12 @@ public static Guid* IID_IStorageProviderStatusUISourceFactory
6684

6785
public static unsafe partial class CLSID
6886
{
87+
[GuidRVAGen.Guid("F0AE1542-F497-484B-A175-A20DB09144BA")]
88+
public static partial Guid* CLSID_AutomaticDestinationList { get; }
89+
90+
[GuidRVAGen.Guid("77F10CF0-3DB5-4966-B520-B7C54FD35ED6")]
91+
public static partial Guid* CLSID_DestinationList { get; }
92+
6993
[GuidRVAGen.Guid("3AD05575-8857-4850-9277-11B85BDB8E09")]
7094
public static partial Guid* CLSID_FileOperation { get; }
7195

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using Windows.Win32.Foundation;
5+
6+
namespace Windows.Win32
7+
{
8+
public class ManualMacros
9+
{
10+
public static bool SUCCEEDED(HRESULT hr)
11+
{
12+
return hr >= 0;
13+
}
14+
15+
public static bool FAILED(HRESULT hr)
16+
{
17+
return hr < 0;
18+
}
19+
}
20+
}

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,4 @@ HCERTSTORE
269269
HCRYPTMSG
270270
CERT_QUERY_ENCODING_TYPE
271271
CertGetNameString
272+
IObjectCollection

src/Files.App.Storage/Windows/Managers/JumpListDestinationType.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Files.App.Storage/Windows/Managers/JumpListItem.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Files.App.Storage/Windows/Managers/JumpListItemType.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)