FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phpmanager/Client/NativeMethods.cs at master · phpmanager/phpmanager · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Mar 9, 2024. It is now read-only.
phpmanager
/
phpmanager
Public archive
Notifications
You must be signed in to change notification settings
Fork
33
Star
207
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
phpmanager
/
Client
/
NativeMethods.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
168 lines (139 loc) · 7.21 KB
Breadcrumbs
phpmanager
/
Client
/
NativeMethods.cs
Copy path
File metadata and controls
168 lines (139 loc) · 7.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
using
System
;
using
System
.
Runtime
.
CompilerServices
;
using
System
.
Runtime
.
InteropServices
;
using
System
.
Runtime
.
InteropServices
.
ComTypes
;
namespace
Web
.
Management
.
PHP
{
static
class
ShowSelectedInExplorer
{
[
Flags
]
enum
SHCONT
:
ushort
{
SHCONTF_CHECKING_FOR_CHILDREN
=
0x0010
,
SHCONTF_FOLDERS
=
0x0020
,
SHCONTF_NONFOLDERS
=
0x0040
,
SHCONTF_INCLUDEHIDDEN
=
0x0080
,
SHCONTF_INIT_ON_FIRST_NEXT
=
0x0100
,
SHCONTF_NETPRINTERSRCH
=
0x0200
,
SHCONTF_SHAREABLE
=
0x0400
,
SHCONTF_STORAGE
=
0x0800
,
SHCONTF_NAVIGATION_ENUM
=
0x1000
,
SHCONTF_FASTITEMS
=
0x2000
,
SHCONTF_FLATLIST
=
0x4000
,
SHCONTF_ENABLE_ASYNC
=
0x8000
}
[
ComImport
,
Guid
(
"000214E6-0000-0000-C000-000000000046"
)
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
)
,
ComConversionLoss
]
interface
IShellFolder
{
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
ParseDisplayName
(
IntPtr
hwnd
,
[
In
,
MarshalAs
(
UnmanagedType
.
Interface
)
]
IBindCtx
pbc
,
[
In
,
MarshalAs
(
UnmanagedType
.
LPWStr
)
]
string
pszDisplayName
,
[
Out
]
out
uint
pchEaten
,
[
Out
]
out
IntPtr
ppidl
,
[
In
,
Out
]
ref
uint
pdwAttributes
)
;
[
PreserveSig
]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
int
EnumObjects
(
[
In
]
IntPtr
hwnd
,
[
In
]
SHCONT
grfFlags
,
[
MarshalAs
(
UnmanagedType
.
Interface
)
]
out
IEnumIDList
ppenumIDList
)
;
[
PreserveSig
]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
int
BindToObject
(
[
In
]
IntPtr
pidl
,
[
In
,
MarshalAs
(
UnmanagedType
.
Interface
)
]
IBindCtx
pbc
,
[
In
]
ref
Guid
riid
,
[
Out
,
MarshalAs
(
UnmanagedType
.
Interface
)
]
out
IShellFolder
ppv
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
BindToStorage
(
[
In
]
ref
IntPtr
pidl
,
[
In
,
MarshalAs
(
UnmanagedType
.
Interface
)
]
IBindCtx
pbc
,
[
In
]
ref
Guid
riid
,
out
IntPtr
ppv
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
CompareIDs
(
[
In
]
IntPtr
lParam
,
[
In
]
ref
IntPtr
pidl1
,
[
In
]
ref
IntPtr
pidl2
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
CreateViewObject
(
[
In
]
IntPtr
hwndOwner
,
[
In
]
ref
Guid
riid
,
out
IntPtr
ppv
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
GetAttributesOf
(
[
In
]
uint
cidl
,
[
In
]
IntPtr
apidl
,
[
In
,
Out
]
ref
uint
rgfInOut
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
GetUIObjectOf
(
[
In
]
IntPtr
hwndOwner
,
[
In
]
uint
cidl
,
[
In
]
IntPtr
apidl
,
[
In
]
ref
Guid
riid
,
[
In
,
Out
]
ref
uint
rgfReserved
,
out
IntPtr
ppv
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
GetDisplayNameOf
(
[
In
]
ref
IntPtr
pidl
,
[
In
]
uint
uFlags
,
out
IntPtr
pName
)
;
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
void
SetNameOf
(
[
In
]
IntPtr
hwnd
,
[
In
]
ref
IntPtr
pidl
,
[
In
,
MarshalAs
(
UnmanagedType
.
LPWStr
)
]
string
pszName
,
[
In
]
uint
uFlags
,
[
Out
]
IntPtr
ppidlOut
)
;
}
[
ComImport
,
Guid
(
"000214F2-0000-0000-C000-000000000046"
)
,
InterfaceType
(
ComInterfaceType
.
InterfaceIsIUnknown
)
]
interface
IEnumIDList
{
[
PreserveSig
]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
int
Next
(
uint
celt
,
IntPtr
rgelt
,
out
uint
pceltFetched
)
;
[
PreserveSig
]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
int
Skip
(
[
In
]
uint
celt
)
;
[
PreserveSig
]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
int
Reset
(
)
;
[
PreserveSig
]
[
MethodImpl
(
MethodImplOptions
.
InternalCall
,
MethodCodeType
=
MethodCodeType
.
Runtime
)
]
int
Clone
(
[
MarshalAs
(
UnmanagedType
.
Interface
)
]
out
IEnumIDList
ppenum
)
;
}
static
class
NativeMethods
{
[
DllImport
(
"shell32.dll"
,
EntryPoint
=
"SHGetDesktopFolder"
,
CharSet
=
CharSet
.
Unicode
,
SetLastError
=
true
)
]
static
extern
int
SHGetDesktopFolder_
(
[
MarshalAs
(
UnmanagedType
.
Interface
)
]
out
IShellFolder
ppshf
)
;
public
static
IShellFolder
SHGetDesktopFolder
(
)
{
IShellFolder
result
;
Marshal
.
ThrowExceptionForHR
(
SHGetDesktopFolder_
(
out
result
)
)
;
return
result
;
}
[
DllImport
(
"shell32.dll"
,
EntryPoint
=
"SHOpenFolderAndSelectItems"
)
]
static
extern
int
SHOpenFolderAndSelectItems_
(
[
In
]
IntPtr
pidlFolder
,
uint
cidl
,
[
In
,
Optional
,
MarshalAs
(
UnmanagedType
.
LPArray
)
]
IntPtr
[
]
apidl
,
int
dwFlags
)
;
public
static
void
SHOpenFolderAndSelectItems
(
IntPtr
pidlFolder
,
IntPtr
[
]
apidl
,
int
dwFlags
)
{
var
cidl
=
(
apidl
!=
null
)
?
(
uint
)
apidl
.
Length
:
0U
;
var
result
=
SHOpenFolderAndSelectItems_
(
pidlFolder
,
cidl
,
apidl
,
dwFlags
)
;
Marshal
.
ThrowExceptionForHR
(
result
)
;
}
[
DllImport
(
"shell32.dll"
)
]
public
static
extern
void
ILFree
(
[
In
]
IntPtr
pidl
)
;
}
static
IntPtr
GetShellFolderChildrenRelativePIDL
(
IShellFolder
parentFolder
,
string
displayName
)
{
uint
pchEaten
;
uint
pdwAttributes
=
0
;
IntPtr
ppidl
;
parentFolder
.
ParseDisplayName
(
IntPtr
.
Zero
,
null
,
displayName
,
out
pchEaten
,
out
ppidl
,
ref
pdwAttributes
)
;
return
ppidl
;
}
static
IntPtr
PathToAbsolutePIDL
(
string
path
)
{
var
desktopFolder
=
NativeMethods
.
SHGetDesktopFolder
(
)
;
return
GetShellFolderChildrenRelativePIDL
(
desktopFolder
,
path
)
;
}
static
Guid
IID_IShellFolder
=
typeof
(
IShellFolder
)
.
GUID
;
static
IShellFolder
PIDLToShellFolder
(
IShellFolder
parent
,
IntPtr
pidl
)
{
IShellFolder
folder
;
var
result
=
parent
.
BindToObject
(
pidl
,
null
,
ref
IID_IShellFolder
,
out
folder
)
;
Marshal
.
ThrowExceptionForHR
(
(
int
)
result
)
;
return
folder
;
}
static
IShellFolder
PIDLToShellFolder
(
IntPtr
pidl
)
{
return
PIDLToShellFolder
(
NativeMethods
.
SHGetDesktopFolder
(
)
,
pidl
)
;
}
static
void
SHOpenFolderAndSelectItems
(
IntPtr
pidlFolder
,
IntPtr
[
]
apidl
,
bool
edit
)
{
NativeMethods
.
SHOpenFolderAndSelectItems
(
pidlFolder
,
apidl
,
edit
?
1
:
0
)
;
}
public
static
void
FileOrFolder
(
string
path
,
bool
edit
=
false
)
{
if
(
path
==
null
)
throw
new
ArgumentNullException
(
"path"
)
;
var
pidl
=
PathToAbsolutePIDL
(
path
)
;
try
{
SHOpenFolderAndSelectItems
(
pidl
,
null
,
edit
)
;
}
finally
{
NativeMethods
.
ILFree
(
pidl
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL