[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]
[MD:1232]w32-shell-execute
- X-ml-count: 1232
- Subject: [MD:1232]w32-shell-execute
- From: Shuichi KITAGUCHI (北口修一) <kit@xxxxxxx>
- Date: Tue, 20 Jul 1999 00:52:29 +0900
- X-mailer: xcite1.27> Mew version 1.94b42 on Emacs 20.4 / Mule 4.0 (HANANOEN)
From: Miyashita Hisashi(宮下 尚:HIMI) <himi@xxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: [MD:1231]w32-shell-execute
Date: 19 Jul 1999 22:37:54 +0900
# Meadow 1.05b1 ダウンロード中...
himi> browse-urlを使うと、何とw32-shell-executeってのを呼ぶようになりました。
あ、嬉しいなぁ、と思ったら、
himi> w32-shell-executeって関数がNTEmacsに入るようになったようですが(at w32fns.c)、
himi> このまま入れるのはどうにも気が進まない(commandlineの統一性にかける
himi> 同期的に動作できない。仕様がごちゃごちゃする。
himi> ついでにどうもバグがあるようだ。;_;)ので、
...(^^;
himi> w32-shell-executeをfiberでemulateしようと思うのですが、fiberで、
himi> ShellExecuteのparamter(sei.lpParameters)と、nShow(sei.nShow)の
himi> 制御ができるように誰か改良してくださらないでしょうか?
というわけで、さくっと -p/-n を付け足しました(1.1.3 へのパッチを添付)。
-p <lpParameters に渡す文字列>
指定されなければ NULL
-n <nShow の値を表す数値>
指定されなければ SW_SHOWNORMAL
何にも考えてない仕様ですが、こんなものでいいでしょうか?
# ついでに ExecuteUnknownExt のデフォルト値も yes に変えてあります。
himi> ## elispも誰か書いてくれるとうれしいなぁ。
PARAMETERS って list なんですよね。コマンドラインへの渡し方が
cygwin や msvc で違った気がするのでとりあえずパス(^^;
# それとも、この場合は単に要素を " " でくっつければいいだけ?
--
Shuichi Kitaguchi <kit@xxxxxxx>--- fiber.c.original Mon Jul 19 23:17:02 1999
+++ fiber.c Mon Jul 19 23:57:08 1999
@@ -1,7 +1,7 @@
/*
* File Inspect and Broking End Resolver -- fiber --
*
- * Copyright (C) 1997,1998 Shuichi Kitaguchi <kit@xxxxxxx>
+ * Copyright (C) 1997,1998,1999 Shuichi Kitaguchi <kit@xxxxxxx>
*
*
* This program is free software; you can redistribute it and/or modify
@@ -34,11 +34,13 @@
* -r num remove ext from database.
* -i initialize database.
* -o Option={num,yes/no} set option.
+ * -p parameters set parameters.
+ * -n show ShowWindow parameter "nCmdShow"
*
* Option | Explanation.(default value)
* ---------------------+------------------------------------------------
* ExtNum | ext max numbers fiber supported
- * ExecuteUnknownExt | execute for unknown file ext.(no)
+ * ExecuteUnknownExt | execute for unknown file ext.(yes)
* ExecuteURL | execute URL(ftp:,http:,...).(yes)
* TrustExt | trust ext that filename has.(yes)
* OverrideExt | override ext if filename has unknown ext.(no)
@@ -145,6 +147,8 @@
* 27 Jun, 1998 : Version 1.1.2 - add SEE_MASK_FLAG_DDEWAIT flag in
* ShellExecuteOpenSync.
* 29 Jun, 1998 : Version 1.1.3 - use ShellExecuteEx if not sync mode.
+ * 19 Jul, 1999 : Version 1.1.4 - add "-p" and "-n" option.
+ * "ExecuteUnknownExt=yes" is default.
*/
@@ -155,7 +159,7 @@
#include <mbstring.h>
-#define FIBER_VERSION "1.1.3"
+#define FIBER_VERSION "1.1.4"
/* constants */
@@ -545,7 +549,7 @@
}
ret = RegSetValueEx( hKey, FIBER_SUBKEY_EXECUTEUNKNOWNEXT, 0,
- REG_BINARY, "\x0", 1 );
+ REG_BINARY, "\x1", 1 );
if ( ret != ERROR_SUCCESS ){
fRet = FALSE;
goto Exit;
@@ -891,7 +895,9 @@
VOID ShellExecuteOpenSync( LPCSTR lpszFileName,
BOOL fSynchronous,
- BOOL fDelete )
+ BOOL fDelete,
+ LPCTSTR lpParameters,
+ int nShow )
{
SHELLEXECUTEINFO sei;
BOOL fRet;
@@ -903,9 +909,9 @@
sei.hwnd = NULL;
sei.lpVerb = NULL;
sei.lpFile = lpszFileName;
- sei.lpParameters = NULL;
+ sei.lpParameters = lpParameters;
sei.lpDirectory = NULL;
- sei.nShow = SW_SHOWNORMAL;
+ sei.nShow = nShow;
sei.hInstApp = 0;
fRet = ShellExecuteEx( &sei );
if ( fRet ){
@@ -924,7 +930,7 @@
VOID PrintUsage( VOID )
{
printf("File Inspect and Broking End Resolver Version %s\n",FIBER_VERSION);
- printf(" Copyright (C) 1997,1998 Shuichi Kitaguchi\n");
+ printf(" Copyright (C) 1997,1998,1999 Shuichi Kitaguchi\n");
printf("\n");
printf("Usage : fiber [optoin] <filename>\n");
printf("Option: -e <ext> set ext\n");
@@ -934,6 +940,8 @@
printf(" -r <num> remove ext from database\n");
printf(" -o Option={num,yes/no} set option\n");
printf(" -i initialize database\n");
+ printf(" -p parameters set parameters\n");
+ printf(" -n show ShowWindow parameter \"nCmdShow\"\n");
}
@@ -956,6 +964,8 @@
BOOL fOption = FALSE;
BOOL fSynchronous = FALSE;
int iRemoveNum;
+ LPCTSTR lpParameters=NULL;
+ int nShow=SW_SHOWNORMAL;
#ifdef _DEBUG
FILE *fp;
#endif
@@ -1026,6 +1036,25 @@
fInitialize = TRUE;
} else if ( ! strcmp(argv[i],"-s") ){
fSynchronous = TRUE;
+ } else if ( ! strcmp(argv[i],"-p") ){
+ /* -p */
+ if ( (i+1) < argc ){
+ lpParameters = argv[i+1];
+ i++;
+ } else {
+ printf("Error: parameters is required with \'-p\' option.\n");
+ fError=TRUE;
+ }
+ } else if ( ! strcmp(argv[i],"-n") ){
+ /* -n */
+ if ( (i+1) < argc ){
+ nShow = atoi(argv[i+1]);
+ if ( nShow == 0 ) nShow = SW_SHOWNORMAL;
+ i++;
+ } else {
+ printf("Error: show is required with \'-n\' option.\n");
+ fError=TRUE;
+ }
} else {
/* filename */
if ( strlen(argv[i]) > sizeof(szInputFile) ){
@@ -1101,10 +1130,10 @@
if ( fExt ){
sprintf(szOpenFile,"%s.%s",szInputFile,szExt);
if ( CheckFile( szOpenFile ) ){
- ShellExecuteOpenSync(szOpenFile,fSynchronous,FALSE);
+ ShellExecuteOpenSync(szOpenFile,fSynchronous,FALSE,lpParameters,nShow);
} else {
CopyFile(szInputFile,szOpenFile,FALSE);
- ShellExecuteOpenSync(szOpenFile,fSynchronous,TRUE);
+ ShellExecuteOpenSync(szOpenFile,fSynchronous,TRUE,lpParameters,nShow);
}
exit( 0 );
} /* if ( fExt ){ */
@@ -1114,7 +1143,7 @@
pt = strchr(szInputFile,':');
if ( pt ){
if ( pt > (szInputFile+1) ){ /* "http:","ftp:",... */
- ShellExecuteOpenSync(szInputFile,fSynchronous,FALSE);
+ ShellExecuteOpenSync(szInputFile,fSynchronous,FALSE,lpParameters,nShow);
exit( 0 );
}
} /* if ( pt ){ */
@@ -1167,15 +1196,15 @@
/* go! */
switch ( state ){
case STATE_INPUTFILE:
- ShellExecuteOpenSync(szInputFile,fSynchronous,FALSE);
+ ShellExecuteOpenSync(szInputFile,fSynchronous,FALSE,lpParameters,nShow);
break;
case STATE_ADDEXT:
sprintf(szOpenFile,"%s.%s",szInputFile,ef[i].szExt);
if ( CheckFile( szOpenFile ) ){
- ShellExecuteOpenSync(szOpenFile,fSynchronous,FALSE);
+ ShellExecuteOpenSync(szOpenFile,fSynchronous,FALSE,lpParameters,nShow);
} else {
CopyFile(szInputFile,szOpenFile,FALSE);
- ShellExecuteOpenSync(szOpenFile,fSynchronous,TRUE);
+ ShellExecuteOpenSync(szOpenFile,fSynchronous,TRUE,lpParameters,nShow);
}
break;
default: