[r16317]: jEditLauncher / trunk / src / jeditext.cpp  Maximize  Restore  History

Download this file

809 lines (695 with data), 23.1 kB

  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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
/*
* jeditext.cpp - jEdit Launcher for Windows (TM).
*
* Context menu shell extension.
*
* Copyright 2004, 2005 Ollie Rutherfurd <oliver@jedit.org>
* Based on code Copyright 1999 Tianmiao Hu
*
* $Id: jeditext.cpp 70 2005-01-10 20:25:50Z orutherfurd $
*/
#include "jeditext.h"
// Always get an error while putting the following stuff to the
// jeditext.h file as class protected variables, give up and
// declare them as global stuff
FORMATETC fmte = {CF_HDROP,
(DVTARGETDEVICE FAR *)NULL,
DVASPECT_CONTENT,
-1,
TYMED_HGLOBAL
};
STGMEDIUM medium;
HRESULT hres = 0;
UINT cbFiles = 0;
UINT g_cRefThisDll = 0; // Reference count of this DLL
HINSTANCE g_hmodThisDll = NULL; // Handle to this DLL itself
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance,
DWORD dwReason,
LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
// Extension DLL one-time initialization
g_hmodThisDll = hInstance;
break;
case DLL_PROCESS_DETACH:
break;
}
return 1; // return TRUE on success
}
static void
inc_cRefThisDLL()
{
InterlockedIncrement((LPLONG)&g_cRefThisDll);
}
static void
dec_cRefThisDLL()
{
InterlockedDecrement((LPLONG)&g_cRefThisDll);
}
//---------------------------------------------------------------------------
// DllCanUnloadNow
//---------------------------------------------------------------------------
STDAPI
DllCanUnloadNow(void)
{
return (g_cRefThisDll == 0 ? S_OK : S_FALSE);
}
STDAPI
DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
{
*ppvOut = NULL;
if (IsEqualIID(rclsid, CLSID_ShellExtension))
{
CShellExtClassFactory *pcf = new CShellExtClassFactory;
return pcf->QueryInterface(riid, ppvOut);
}
return CLASS_E_CLASSNOTAVAILABLE;
}
//---------------------------------------------------------------------------
// Register/Unregister Server
//---------------------------------------------------------------------------
STDAPI
DllRegisterServer(void)
{
DWORD dwDisp;
HKEY hKey;
LONG result = 0;
OSVERSIONINFO osvi;
char path[MAX_PATH] = {'\0'};
char value[MAX_PATH] = {'\0'};
if(!GetModuleFileName(g_hmodThisDll, path, MAX_PATH))
return E_FAIL;
// [HKEY_CLASSES_ROOT\CLSID\{F1763C8F-4F26-4a15-943F-2CA281BD3385}]
// @="jEdit Shell Extension"
result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
"CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
&dwDisp);
if(result == ERROR_SUCCESS)
{
// @="jEdit Shell Extension"
strcpy(value,"jEdit Shell Extension");
RegSetValueEx(hKey,
NULL,
0,
REG_SZ,
(LPBYTE)value,
(DWORD)strlen(value) + 1);
RegCloseKey(hKey);
}
else
return E_FAIL;
// [HKEY_CLASSES_ROOT\CLSID\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\InProcServer32]
// @="C:\\Sandbox\\jedit.exe\\jeditext.dll"
// "ThreadingModel"="Apartment"
result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
"CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\\InProcServer32",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
&dwDisp);
if(result == ERROR_SUCCESS)
{
// @="C:\\Sandbox\\jedit.exe\\jeditext.dll"
strcpy(value,path);
RegSetValueEx(hKey,
NULL,
0,
REG_SZ,
(LPBYTE)value,
(DWORD)strlen(value) + 1);
// "ThreadingModel"="Apartment"
strcpy(value,"Apartment");
RegSetValueEx(hKey,
"ThreadingModel",
0,
REG_SZ,
(LPBYTE)value,
(DWORD)strlen(value) + 1);
RegCloseKey(hKey);
}
else
return E_FAIL;
// [HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\jedit]
// @="{F1763C8F-4F26-4a15-943F-2CA281BD3385}"
result = RegCreateKeyEx(HKEY_CLASSES_ROOT,
"*\\shellex\\ContextMenuHandlers\\jedit",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
&dwDisp);
if(result == ERROR_SUCCESS)
{
// @="{F1763C8F-4F26-4a15-943F-2CA281BD3385}"
strcpy(value,"{F1763C8F-4F26-4a15-943F-2CA281BD3385}");
RegSetValueEx(hKey,
NULL,
0,
REG_SZ,
(LPBYTE)value,
(DWORD)strlen(value) + 1);
RegCloseKey(hKey);
}
else
return E_FAIL;
// [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]
// "{F1763C8F-4F26-4a15-943F-2CA281BD3385}"="jEdit Shell Extension"
// (only on NT)
osvi.dwOSVersionInfoSize = sizeof(osvi);
GetVersionEx(&osvi);
if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
{
result = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
&dwDisp);
if(result == ERROR_SUCCESS)
{
// "{F1763C8F-4F26-4a15-943F-2CA281BD3385}"="jEdit Shell Extension"
strcpy(value,"jEdit Shell Extension");
RegSetValueEx(hKey,
"{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
0,
REG_SZ,
(LPBYTE)value,
(DWORD)strlen(value) + 1);
RegCloseKey(hKey);
}
}
else
return E_FAIL;
return NOERROR;
}
STDAPI
DllUnregisterServer(void)
{
char msg[1024] = {'\0'};
char error[255] = {'\0'};
const HKEY roots[] = {
HKEY_CLASSES_ROOT,
HKEY_LOCAL_MACHINE,
HKEY_CLASSES_ROOT,
HKEY_CLASSES_ROOT,
};
const char* keys[] = {
"*\\shellex\\ContextMenuHandlers\\jedit",
"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
"CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}\\InProcServer32",
"CLSID\\{F1763C8F-4F26-4a15-943F-2CA281BD3385}",
};
LONG results[] = {0,0,0,0};
int i;
for(i=0; i < 4; i++)
{
results[i] = RegDeleteKey(roots[i], keys[i]);
if(results[i] != ERROR_SUCCESS && results[i] != ERROR_FILE_NOT_FOUND)
{
error[0] = 0;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
results[i],
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
error,
255,
NULL);
sprintf(msg, "Error removing: %s\n%s", keys[i], error);
MessageBox(NULL, msg, "Problem Deleting Registry Key", MB_OK);
}
}
for(i=0; i < 4; i++)
if(results[i] != ERROR_SUCCESS && results[i] != ERROR_FILE_NOT_FOUND)
return E_FAIL;
return NOERROR;
}
CShellExtClassFactory::CShellExtClassFactory()
{
m_cRef = 0L;
inc_cRefThisDLL();
}
CShellExtClassFactory::~CShellExtClassFactory()
{
dec_cRefThisDLL();
}
STDMETHODIMP
CShellExtClassFactory::QueryInterface(REFIID riid,
LPVOID FAR *ppv)
{
*ppv = NULL;
// Any interface on this object is the object pointer
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IClassFactory))
{
*ppv = (LPCLASSFACTORY)this;
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG)
CShellExtClassFactory::AddRef()
{
return InterlockedIncrement((LPLONG)&m_cRef);
}
STDMETHODIMP_(ULONG)
CShellExtClassFactory::Release()
{
if (InterlockedDecrement((LPLONG)&m_cRef))
return m_cRef;
delete this;
return 0L;
}
STDMETHODIMP
CShellExtClassFactory::CreateInstance(LPUNKNOWN pUnkOuter,
REFIID riid,
LPVOID *ppvObj)
{
*ppvObj = NULL;
// Shell extensions typically don't support aggregation (inheritance)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
// Create the main shell extension object. The shell will then call
// QueryInterface with IID_IShellExtInit--this is how shell extensions are
// initialized.
LPCSHELLEXT pShellExt = new CShellExt(); //Create the CShellExt object
if (NULL == pShellExt)
return E_OUTOFMEMORY;
return pShellExt->QueryInterface(riid, ppvObj);
}
STDMETHODIMP
CShellExtClassFactory::LockServer(BOOL fLock)
{
return NOERROR;
}
CShellExt::CShellExt()
{
hImage = (HBITMAP)LoadImage(g_hmodThisDll,
MAKEINTRESOURCE(102),
IMAGE_BITMAP,
0,
0,
LR_DEFAULTSIZE|LR_LOADTRANSPARENT);
m_cRef = 0L;
m_pDataObj = NULL;
inc_cRefThisDLL();
}
CShellExt::~CShellExt()
{
if (m_pDataObj)
m_pDataObj->Release();
if (hImage)
DeleteObject(hImage);
dec_cRefThisDLL();
}
STDMETHODIMP
CShellExt::QueryInterface(REFIID riid, LPVOID FAR *ppv)
{
*ppv = NULL;
if (IsEqualIID(riid, IID_IShellExtInit) || IsEqualIID(riid, IID_IUnknown))
{
*ppv = (LPSHELLEXTINIT)this;
}
else if (IsEqualIID(riid, IID_IContextMenu))
{
*ppv = (LPCONTEXTMENU)this;
}
if (*ppv)
{
AddRef();
return NOERROR;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG)
CShellExt::AddRef()
{
return InterlockedIncrement((LPLONG)&m_cRef);
}
STDMETHODIMP_(ULONG)
CShellExt::Release()
{
if (InterlockedDecrement((LPLONG)&m_cRef))
return m_cRef;
delete this;
return 0L;
}
//
// FUNCTION: CShellExt::Initialize(LPCITEMIDLIST, LPDATAOBJECT, HKEY)
//
// PURPOSE: Called by the shell when initializing a context menu or property
// sheet extension.
//
// PARAMETERS:
// pIDFolder - Specifies the parent folder
// pDataObj - Specifies the set of items selected in that folder.
// hRegKey - Specifies the type of the focused item in the selection.
//
// RETURN VALUE:
//
// NOERROR in all cases.
//
// COMMENTS: Note that at the time this function is called, we don't know
// (or care) what type of shell extension is being initialized.
// It could be a context menu or a property sheet.
//
STDMETHODIMP
CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
LPDATAOBJECT pDataObj,
HKEY hRegKey)
{
// Initialize can be called more than once
if (m_pDataObj)
m_pDataObj->Release();
// duplicate the object pointer and registry handle
if (pDataObj)
{
m_pDataObj = pDataObj;
pDataObj->AddRef();
}
return NOERROR;
}
//
// FUNCTION: CShellExt::QueryContextMenu(HMENU, UINT, UINT, UINT, UINT)
//
// PURPOSE: Called by the shell just before the context menu is displayed.
// This is where you add your specific menu items.
//
// PARAMETERS:
// hMenu - Handle to the context menu
// indexMenu - Index of where to begin inserting menu items
// idCmdFirst - Lowest value for new menu ID's
// idCmtLast - Highest value for new menu ID's
// uFlags - Specifies the context of the menu event
//
STDMETHODIMP
CShellExt::QueryContextMenu(HMENU hMenu,
UINT indexMenu,
UINT idCmdFirst,
UINT idCmdLast,
UINT uFlags)
{
UINT idCmd = idCmdFirst;
char label[MAX_PATH] = {'\0'};
char ext[MAX_PATH] = {'\0'};
char path[MAX_PATH] = {'\0'};
char filename[MAX_PATH] = {'\0'};
char drive[MAX_PATH] = {'\0'};
char directory[MAX_PATH] = {'\0'};
hres = m_pDataObj->GetData(&fmte, &medium);
// get number of files selected
if (medium.hGlobal)
cbFiles = DragQueryFile((HDROP)medium.hGlobal, (UINT)-1, 0, 0);
InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
InsertMenu(hMenu,
indexMenu++,
MF_STRING|MF_BYPOSITION,
idCmd++,
"Open with &jEdit");
SetMenuItemBitmaps(hMenu,
indexMenu-1,
MF_BYPOSITION,
hImage,
hImage);
if(cbFiles == 2)
{
// Can edit up to 4 files in diff mode
InsertMenu(hMenu,
indexMenu++,
MF_STRING|MF_BYPOSITION,
idCmd++,
"&Diff with jEdit");
SetMenuItemBitmaps(hMenu,
indexMenu-1,
MF_BYPOSITION,
hImage,
hImage);
}
else if(cbFiles == 1)
{
DragQueryFile((HDROP)medium.hGlobal,
0,
path,
MAX_PATH);
_splitpath_s(path,drive,directory,filename,ext);
if(ext && strlen(ext))
{
sprintf(label, "Open &*%s with jEdit", ext);
InsertMenu(hMenu,
indexMenu++,
MF_STRING|MF_BYPOSITION,
idCmd++,
label);
SetMenuItemBitmaps(hMenu,
indexMenu-1,
MF_BYPOSITION,
hImage,
hImage);
}
}
InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL);
// Must return number of menu items we added.
return ResultFromShort(idCmd-idCmdFirst);
}
STDMETHODIMP
CShellExt::GetCommandString(UINT_PTR idCmd,
UINT uFlags,
UINT FAR *reserved,
LPSTR pszName,
UINT cchMax)
{
if (uFlags == GCS_HELPTEXT && cchMax > 35)
{
if(idCmd == 0)
lstrcpy(pszName, "Open the selected file(s) with jEdit");
else if(cbFiles == 2)
{
lstrcpy(pszName, "Diff the selected files with jEdit");
}
else
{
lstrcpy(pszName, "Open matching files with jEdit");
}
}
return NOERROR;
}
//
// FUNCTION: CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO)
//
// PURPOSE: Called by the shell after the user has selected on of the
// menu items that was added in QueryContextMenu().
//
// PARAMETERS:
// lpcmi - Pointer to an CMINVOKECOMMANDINFO structure
//
STDMETHODIMP
CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
{
HRESULT hr = E_INVALIDARG;
// If HIWORD(lpcmi->lpVerb) then we have been called programmatically
// and lpVerb is a command that should be invoked. Otherwise, the shell
// has called us, and LOWORD(lpcmi->lpVerb) is the menu ID the user has
// selected. Actually, it's (menu ID - idCmdFirst) from QueryContextMenu().
if (!HIWORD(lpcmi->lpVerb))
{
UINT idCmd = LOWORD(lpcmi->lpVerb);
switch (idCmd)
{
case 0:
hr = OpenInJEdit(lpcmi->hwnd,
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow);
break;
case 1:
if(cbFiles == 2)
{
hr = DiffWithJEdit(lpcmi->hwnd,
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow);
}
else
{
hr = OpenByExtInJEdit(lpcmi->hwnd,
lpcmi->lpDirectory,
lpcmi->lpVerb,
lpcmi->lpParameters,
lpcmi->nShow);
}
break;
}
}
return hr;
}
STDMETHODIMP
CShellExt::DiffWithJEdit(HWND hParent,
LPCSTR pszWorkingDir,
LPCSTR pszCmd,
LPCSTR pszParam,
int iShowCmd)
{
LaunchConfig config;
char file1[MAX_PATH] = {'\0'};
char file2[MAX_PATH] = {'\0'};
if(cbFiles != 2)
return E_FAIL; // expecting 2 args
DragQueryFile((HDROP)medium.hGlobal,
0,
file1,
MAX_PATH);
DragQueryFile((HDROP)medium.hGlobal,
1,
file2,
MAX_PATH);
if(get_launch_config(&config))
{
MessageBox(hParent,
"Failed to get jEdit & Java configuration from registry.\n"
"\n"
"See 'jeditlauncher.log' in your HOME directory for details.",
"Can't open jEdit",
MB_OK);
return E_FAIL;
}
if(!diff_files_in_jedit(config.java,
config.java_opts,
config.jedit_jar,
config.jedit_opts,
config.working_dir,
file1,
file2))
return NOERROR;
return E_FAIL;
}
STDMETHODIMP
CShellExt::OpenByExtInJEdit(HWND hParent,
LPCSTR pszWorkingDir,
LPCSTR pszCmd,
LPCSTR pszParam,
int iShowCmd)
{
LaunchConfig config;
char** files = 0;
int nfiles = 0;
char* globs[] = {'\0'};
char glob[MAX_PATH] = {'\0'};
char directory[MAX_PATH] = {'\0'};
char drive[MAX_PATH] = {'\0'};
char ext[MAX_PATH] = {'\0'};
char filename[MAX_PATH] = {'\0'};
char path[MAX_PATH] = {'\0'};
DragQueryFile((HDROP)medium.hGlobal,
0,
path,
MAX_PATH);
// split path into chunks, so we can find
// all matching files in the directory
_splitpath_s(path,drive,directory,filename,ext);
// <drive>\<dir>\*<ext>
sprintf(glob,"%s%s*%s", drive, directory, ext);
// find number of files
globs[0] = glob;
nfiles = -1 * expand_globs((const char**)globs,
1,
files,
0);
// allocate file list
int nalloc = (nfiles) * sizeof(char*);
files = (char**)malloc(nalloc);
if(!files)
return E_OUTOFMEMORY;
// fill the file list
nfiles = expand_globs((const char**)&globs,
1,
files,
nfiles);
if(get_launch_config(&config))
{
MessageBox(hParent,
"Failed to get jEdit & Java configuration from registry.\n"
"\n"
"See 'jeditlauncher.log' in your HOME directory for details.",
"Can't open jEdit",
MB_OK);
return E_FAIL;
}
// XXX handle error
open_files_in_jedit(config.java,
config.java_opts,
config.jedit_jar,
config.jedit_opts,
config.working_dir,
NULL, // no command-line options
(const char**)files,
nfiles);
return NOERROR;
}
STDMETHODIMP
CShellExt::OpenInJEdit(HWND hParent,
LPCSTR pszWorkingDir,
LPCSTR pszCmd,
LPCSTR pszParam,
int iShowCmd)
{
int r = 0;
LaunchConfig config;
char** files = 0;
UINT i;
files = (char**)malloc(sizeof(char*) * cbFiles);
if(!files)
return E_OUTOFMEMORY;
for(i=0; i < cbFiles; i++)
{
files[i] = (char*)malloc(sizeof(char) * MAX_PATH);
if(!files[i])
return E_OUTOFMEMORY;
DragQueryFile((HDROP)medium.hGlobal,
i,
files[i],
MAX_PATH);
}
if(get_launch_config(&config))
{
MessageBox(hParent,
"Failed to get jEdit & Java configuration from registry.\n"
"\n"
"See 'jeditlauncher.log' in your HOME directory for details.",
"Can't open jEdit",
MB_OK);
return E_FAIL;
}
r = open_files_in_jedit(config.java,
config.java_opts,
config.jedit_jar,
config.jedit_opts,
config.working_dir,
NULL, // no command-line options
(const char**)files,
cbFiles);
// free files and file list
for(i=0; i < cbFiles; i++)
free(files[i]);
free(files);
if(r)
return E_FAIL;
return NOERROR;
}