// 参考 https://qiita.com/DandyMania/items/d1404c313f67576d395f private IntPtr wndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { if (msg == WinApi.WM_DROPFILES) { IntPtr hDrop = wParam; uint num = WinApi.DragQueryFile(hDrop, 0xFFFFFFFF, null, 0); string[] files = new string[num]; uint bufferSize = 1024; StringBuilder path = new StringBuilder((int)bufferSize); for (uint i = 0; i < num; i++) { //uint size = WinApi.DragQueryFile(hDrop, i, path, bufferSize); WinApi.DragQueryFile(hDrop, i, path, bufferSize); files[i] = path.ToString(); path.Length = 0; } WinApi.DragFinish(hDrop); if (OnFilesDropped != null) { OnFilesDropped(files); } } return(WinApi.CallWindowProc(oldWndProcPtr, hWnd, msg, wParam, lParam)); }