回答編集履歴
2
リンク修正
test
CHANGED
@@ -208,6 +208,4 @@
|
|
208
208
|
|
209
209
|
|
210
210
|
|
211
|
-
まとめ記事。[
|
212
|
-
|
213
|
-
|
211
|
+
[まとめ記事]( http://mojakouinfotaker.blog.fc2.com/blog-entry-867.html)
|
1
解決方法を追記
test
CHANGED
@@ -104,6 +104,110 @@
|
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
+
解決方法
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```C#
|
112
|
+
|
113
|
+
public delegate bool EnumWindowCallBack(IntPtr hwnd, IntPtr lParam);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
[DllImport("USER32.DLL", EntryPoint = "FindWindowEx")]
|
118
|
+
|
119
|
+
private static extern IntPtr FindWindowEx(IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2);
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
// SetParent 関数
|
124
|
+
|
125
|
+
[DllImport("USER32.DLL", CharSet = CharSet.Auto)]
|
126
|
+
|
127
|
+
private static extern System.IntPtr SetParent(
|
128
|
+
|
129
|
+
System.IntPtr hWndChild,
|
130
|
+
|
131
|
+
System.IntPtr hWndNewParent
|
132
|
+
|
133
|
+
);
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
[DllImport("USER32.Dll")]
|
138
|
+
|
139
|
+
static extern int EnumWindows(EnumWindowCallBack x, IntPtr y);
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
[DllImport("User32.Dll", CharSet = CharSet.Unicode)]
|
144
|
+
|
145
|
+
public static extern int GetClassName(IntPtr hWnd, StringBuilder s, int nMaxCount);
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
// ウィンドウを列挙するためのコールバックメソッド
|
154
|
+
|
155
|
+
private bool EnumerateWindow(IntPtr hWnd, IntPtr lParam)
|
156
|
+
|
157
|
+
{
|
158
|
+
|
159
|
+
StringBuilder sbClassName = new StringBuilder(256);
|
160
|
+
|
161
|
+
int result = GetClassName(hWnd, sbClassName, 256);
|
162
|
+
|
163
|
+
string className = sbClassName.ToString();
|
164
|
+
|
165
|
+
if (className.Equals("WorkerW") || className.Equals("Progman"))
|
166
|
+
|
167
|
+
{
|
168
|
+
|
169
|
+
IntPtr hDt = FindWindowEx(hWnd, IntPtr.Zero, "SHELLDLL_DefView", null);
|
170
|
+
|
171
|
+
//↑この"SHELLDLL_DefView"がキモ。このクラス名が入っていな //いと、Program Managerだろうと何だろうとデスクトップウィンドウを取得できない。
|
172
|
+
|
173
|
+
if (hDt != null && hDt != IntPtr.Zero)
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
SetParent(this.Handle, hDt);
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
return true;
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
private void button1_Click_1(object sender, EventArgs e)
|
192
|
+
|
193
|
+
{
|
194
|
+
|
195
|
+
EnumWindows(EnumerateWindow, IntPtr.Zero);
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
```
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
107
211
|
まとめ記事。[
|
108
212
|
|
109
213
|
http://mojakouinfotaker.blog.fc2.com/blog-entry-867.html]( http://mojakouinfotaker.blog.fc2.com/blog-entry-867.html)
|