placeholder implementation of explorer.exe

Dan Kegel dank at kegel.com
Sun Jan 19 19:48:29 CST 2003


Sylvain Petreolle wrote:
> I think that Dan has a shorter and better solution.
> After all its easier to fix the existing code and write a wrapper than
> coding a new program.

OK, then.  Here's a patch that makes 'start explorer.exe d:\' work
(needed by msvc4.0's setup program).

Note that winefile had not in the past been installed in the
fake windows area.  This patch causes it to be installed there,
and indeed under the name 'winfile.exe'.  Hope that's ok.

I'm tempted to wait until somebody else agrees that this
works before posting it to wine-patches...
- Dan

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045
-------------- next part --------------
Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.122
diff -u -r1.122 configure.ac
--- configure.ac	15 Jan 2003 00:50:48 -0000	1.122
+++ configure.ac	20 Jan 2003 01:22:37 -0000
@@ -1510,6 +1510,7 @@
 programs/cmdlgtst/Makefile
 programs/control/Makefile
 programs/expand/Makefile
+programs/explorer/Makefile
 programs/notepad/Makefile
 programs/osversioncheck/Makefile
 programs/progman/Makefile
Index: programs/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/Makefile.in,v
retrieving revision 1.33
diff -u -r1.33 Makefile.in
--- programs/Makefile.in	4 Jan 2003 02:52:05 -0000	1.33
+++ programs/Makefile.in	20 Jan 2003 01:22:37 -0000
@@ -10,6 +10,7 @@
 	cmdlgtst \
 	control \
 	expand \
+	explorer \
 	notepad \
 	osversioncheck \
 	progman \
@@ -37,6 +38,7 @@
 	clock \
 	control \
 	expand \
+	explorer \
 	notepad \
 	progman \
 	regedit \
@@ -73,6 +75,7 @@
 
 # Symlinks to apps that we want to run from inside the source tree
 SYMLINKS = \
+	explorer.exe \
 	rpcss.exe \
 	wcmd.exe \
 	wineconsole.exe \
@@ -121,6 +124,9 @@
 check test:: $(SUBDIRS:%=%/__test__)
 
 # Rules for symlinks
+
+explorer.exe$(DLLEXT): explorer/explorer.exe$(DLLEXT)
+	$(RM) $@ && $(LN_S) explorer/explorer.exe$(DLLEXT) $@
 
 rpcss.exe$(DLLEXT): rpcss/rpcss.exe$(DLLEXT)
 	$(RM) $@ && $(LN_S) rpcss/rpcss.exe$(DLLEXT) $@
Index: tools/wineinstall
===================================================================
RCS file: /home/wine/wine/tools/wineinstall,v
retrieving revision 1.50
diff -u -r1.50 wineinstall
--- tools/wineinstall	5 Dec 2002 19:05:44 -0000	1.50
+++ tools/wineinstall	20 Jan 2003 01:22:37 -0000
@@ -135,6 +135,8 @@
   link_app wcmd         "$CROOT/windows/system/wcmd.exe"
   link_app control      "$CROOT/windows/system/control.exe"
   link_app winhelp      "$CROOT/windows/system/help.exe"
+  link_app winefile     "$CROOT/windows/winfile.exe"
+  link_app explorer     "$CROOT/windows/explorer.exe"
   link_app notepad      "$CROOT/windows/system/notepad.exe"
   link_app progman      "$CROOT/windows/system/progman.exe"
   link_app regsvr32     "$CROOT/windows/system/regsvr32.exe"
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ programs/explorer/Makefile.in	2003-01-19 17:09:38.000000000 -0800
@@ -0,0 +1,13 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = explorer.exe
+APPMODE   = cui
+IMPORTS   = shell32
+
+C_SRCS = explorer.c
+
+ at MAKE_PROG_RULES@
+
+### Dependencies:
--- /dev/null	2002-08-30 16:31:37.000000000 -0700
+++ programs/explorer/explorer.c	2003-01-19 17:15:23.000000000 -0800
@@ -0,0 +1,86 @@
+/*
+ * Wrapper around win[e]file to make it act like explorer
+ * This is all wrong, but it works well enough if you're passing
+ * no arguments, or just a directory name
+ *
+ * Copyright 2003 Dan Kegel
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <windows.h>
+#include <winuser.h>
+#include <shlobj.h>
+#include <stdio.h>
+
+/**
+ Output given message to stdout without formatting.
+*/
+static void output(const char *message)
+{
+	DWORD count;
+	WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), message, strlen(message), &count, NULL);
+}
+
+/**
+ Output given message,
+ followed by ": ",
+ followed by description of given GetLastError() value to stdout,
+ followed by a trailing newline,
+ then terminate.
+*/
+static void fatal_error(const char *msg, DWORD error_code)
+{
+	LPVOID lpMsgBuf;
+	int status;
+
+	output(msg);
+	output(": ");
+	status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0, (LPTSTR) & lpMsgBuf, 0, NULL);
+	if (!status) {
+		output("FormatMessage failed\n");
+	} else {
+		output(lpMsgBuf);
+		LocalFree((HLOCAL) lpMsgBuf);
+		output("\n");
+	}
+	ExitProcess(1);
+}
+
+int main(int argc, char *argv[])
+{
+	SHELLEXECUTEINFO sei;
+
+	memset(&sei, 0, sizeof(sei));
+	sei.cbSize = sizeof(sei);
+	sei.lpVerb = "open";
+	sei.nShow = SW_SHOWNORMAL;
+	/* Dunno what these mean, but it looks like winMe's start uses them */
+	sei.fMask = SEE_MASK_FLAG_DDEWAIT|SEE_MASK_FLAG_NO_UI;
+
+	if (argc > 1) {
+		if (!SetCurrentDirectory(argv[1])) {
+			fatal_error(argv[1], GetLastError());
+		}
+	}
+
+	sei.lpFile = "winfile.exe";
+	sei.lpParameters = NULL;
+
+	if (!ShellExecuteEx(&sei))
+	    	fatal_error("can't exec", GetLastError());
+
+	ExitProcess(0);
+}


More information about the wine-devel mailing list