comparison src/objects-msw.c @ 359:8e84bee8ddd0 r21-1-9

Import from CVS: tag r21-1-9
author cvs
date Mon, 13 Aug 2007 10:57:55 +0200
parents 4711e16a8e49
children 7347b34c275b
comparison
equal deleted inserted replaced
358:fed6e0f6a03a 359:8e84bee8ddd0
1462 return build_string ("Courier New:Regular:10"); 1462 return build_string ("Courier New:Regular:10");
1463 } 1463 }
1464 1464
1465 #endif /* MULE */ 1465 #endif /* MULE */
1466 1466
1467 DEFUN ("mswindows-shell-execute", Fmswindows_shell_execute, 2, 4, 0, /*
1468 Get Windows to perform OPERATION on DOCUMENT.
1469 This is a wrapper around the ShellExecute system function, which
1470 invokes the application registered to handle OPERATION for DOCUMENT.
1471 OPERATION is typically \"open\", \"print\" or \"explore\" (but can be
1472 nil for the default action), and DOCUMENT is typically the name of a
1473 document file or URL, but can also be a program executable to run or
1474 a directory to open in the Windows Explorer.
1475
1476 If DOCUMENT is a program executable, PARAMETERS can be a string
1477 containing command line parameters, but otherwise should be nil.
1478
1479 SHOW-FLAG can be used to control whether the invoked application is hidden
1480 or minimized. If SHOW-FLAG is nil, the application is displayed normally,
1481 otherwise it is an integer representing a ShowWindow flag:
1482
1483 0 - start hidden
1484 1 - start normally
1485 3 - start maximized
1486 6 - start minimized
1487 */
1488 (operation, document, parameters, show_flag))
1489 {
1490 /* Encode filename and current directory. */
1491 Lisp_Object current_dir = Ffile_name_directory (document);
1492 char* path = NULL;
1493 char* doc = NULL;
1494 Extbyte* f=0;
1495 int ret;
1496 struct gcpro gcpro1, gcpro2;
1497
1498 CHECK_STRING (document);
1499
1500 /* Just get the filename if we were given it. */
1501 document = Ffile_name_nondirectory (document);
1502
1503 if (NILP (current_dir))
1504 current_dir = current_buffer->directory;
1505
1506 GCPRO2 (current_dir, document);
1507
1508 /* Use mule and cygwin-safe APIs top get at file data. */
1509 if (STRINGP (current_dir))
1510 {
1511 GET_C_STRING_FILENAME_DATA_ALLOCA (current_dir, f);
1512 #ifdef __CYGWIN32__
1513 CYGWIN_WIN32_PATH (f, path);
1514 #else
1515 path = f;
1516 #endif
1517 }
1518
1519 if (STRINGP (document))
1520 {
1521 GET_C_STRING_FILENAME_DATA_ALLOCA (document, f);
1522 doc = f;
1523 }
1524
1525 UNGCPRO;
1526
1527 ret = (int) ShellExecute (NULL,
1528 (STRINGP (operation) ?
1529 XSTRING_DATA (operation) : NULL),
1530 doc,
1531 (STRINGP (parameters) ?
1532 XSTRING_DATA (parameters) : NULL),
1533 path,
1534 (INTP (show_flag) ?
1535 XINT (show_flag) : SW_SHOWDEFAULT));
1536
1537 if (ret > 32)
1538 return Qt;
1539
1540 if (ret == ERROR_FILE_NOT_FOUND || ret == SE_ERR_FNF)
1541 signal_simple_error ("file not found", document);
1542 else if (ret == ERROR_PATH_NOT_FOUND || ret == SE_ERR_PNF)
1543 signal_simple_error ("path not found", current_dir);
1544 else if (ret == ERROR_BAD_FORMAT)
1545 signal_simple_error ("bad executable format", document);
1546 else
1547 error ("internal error");
1548
1549 return Qnil;
1550 }
1551
1467 1552
1468 /************************************************************************/ 1553 /************************************************************************/
1469 /* non-methods */ 1554 /* non-methods */
1470 /************************************************************************/ 1555 /************************************************************************/
1471 1556
1491 1576
1492 void 1577 void
1493 syms_of_objects_mswindows (void) 1578 syms_of_objects_mswindows (void)
1494 { 1579 {
1495 DEFSUBR (Fmswindows_color_list); 1580 DEFSUBR (Fmswindows_color_list);
1581 DEFSUBR (Fmswindows_shell_execute);
1496 } 1582 }
1497 1583
1498 void 1584 void
1499 console_type_create_objects_mswindows (void) 1585 console_type_create_objects_mswindows (void)
1500 { 1586 {