explorer.exe

Aric Stewart aric at codeweavers.com
Tue Nov 15 14:20:47 CST 2005


Here is the beginning of an explorer.exe replacement that wraps the 
existing winefile program.
It lacks a number of aspects of functionality such as /select, and /n 
however it does bring up the winefile window pointed at the correct 
directory.

-aric
-------------- next part --------------
Index: programs/Makefile.in
===================================================================
RCS file: /home/wine/wine/programs/Makefile.in,v
retrieving revision 1.49
diff -u -r1.49 Makefile.in
--- programs/Makefile.in	31 Oct 2005 21:10:38 -0000	1.49
+++ programs/Makefile.in	15 Nov 2005 20:17:55 -0000
@@ -12,6 +12,7 @@
 	control \
 	eject \
 	expand \
+	explorer \
 	hh \
 	msiexec \
 	notepad \
@@ -46,6 +47,7 @@
 	control \
 	eject \
 	expand \
+	explorer \
 	hh \
 	msiexec \
 	notepad \
@@ -100,6 +102,7 @@
 	control.exe$(DLLEXT) \
 	eject.exe$(DLLEXT) \
 	expand.exe$(DLLEXT) \
+	explorer.exe$(DLLEXT) \
 	hh.exe$(DLLEXT) \
 	icinfo.exe$(DLLEXT) \
 	msiexec.exe$(DLLEXT) \
@@ -192,6 +195,9 @@
 expand.exe$(DLLEXT): expand/expand.exe$(DLLEXT)
 	$(RM) $@ && $(LN_S) expand/expand.exe$(DLLEXT) $@
 
+explorer.exe$(DLLEXT): explorer/explorer.exe$(DLLEXT)
+	$(RM) $@ && $(LN_S) explorer/explorer.exe$(DLLEXT) $@
+
 hh.exe$(DLLEXT): hh/hh.exe$(DLLEXT)
 	$(RM) $@ && $(LN_S) hh/hh.exe$(DLLEXT) $@
 
@@ -280,6 +286,7 @@
 control/control.exe$(DLLEXT): control
 eject/eject.exe$(DLLEXT): eject
 expand/expand.exe$(DLLEXT): expand
+explorer/explorer.exe$(DLLEXT): explorer
 hh/hh.exe$(DLLEXT): hh
 avitools/icinfo.exe$(DLLEXT): avitools
 msiexec/msiexec.exe$(DLLEXT): msiexec
--- /dev/null	2005-03-17 08:20:53.000000000 -0600
+++ programs/explorer/Makefile.in	2005-11-15 08:22:37.000000000 -0600
@@ -0,0 +1,20 @@
+EXTRADEFS = -D__WINE__ -DUNICODE
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = explorer.exe
+APPMODE   = -mwindows
+IMPORTS   = user32 kernel32
+EXTRALIBS = -luuid
+
+C_SRCS = \
+	explorer.c
+
+RC_SRCS = 
+RC_BINSRC = 
+RC_BINARIES =
+
+ at MAKE_PROG_RULES@
+
+### Dependencies:
--- /dev/null	2005-03-17 08:20:53.000000000 -0600
+++ programs/explorer/explorer.c	2005-11-15 12:11:12.000000000 -0600
@@ -0,0 +1,169 @@
+/*
+ * explorer.exe
+ *
+ * Copyright 2005 CodeWeavers, Aric Stewart
+ *
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <windows.h>
+#include "ctype.h"
+
+
+typedef struct parametersTAG {
+    BOOL    explorer_mode;
+    WCHAR   root[MAX_PATH];
+    WCHAR   selection[MAX_PATH];
+} parameters_struct;
+
+
+int CopyPathString(LPWSTR target, LPSTR source)
+{
+    CHAR temp_buf[MAX_PATH];
+    INT i = 0;
+
+    while isspace(*source)
+        source++;
+
+    if (*source == '\"')
+    {
+        source ++;
+        while (*source != '\"')
+        {
+            temp_buf[i] = *source;
+            i++;
+            source++;
+        }
+        temp_buf[i] = 0;
+        source ++;
+        i+=2;
+    }
+    else
+    {
+        while (*source && !isspace(*source))
+        {
+            temp_buf[i] = *source;
+            i++;
+            source++;
+        }
+        temp_buf[i] = 0;
+    }
+    MultiByteToWideChar(CP_ACP,0,temp_buf,-1,target,MAX_PATH);
+    return i;
+}
+
+
+void CopyPathRoot(LPWSTR root, LPWSTR path)
+{
+    LPWSTR p,p2;
+    INT i = 0;
+
+    p = path;
+    while (*p!=0)
+        p++;
+
+    while (*p!='\\' && p > path)
+        p--;
+
+    if (p == path)
+        return;
+
+    p2 = path;
+    while (p2 != p)
+    {
+        root[i] = *p2;
+        i++;
+        p2++;
+    }
+    root[i] = 0;
+}
+
+/*
+ * Command Line parameters are:
+ * [/n]  Opens in single-paned view for each selected items. This is default
+ * [/e,] Uses Windows Explorer View
+ * [/root,object] Specifies the root level of the view
+ * [/select,object] parent folder is opened and specified object is selected
+ */
+void ParseCommandLine(LPSTR commandline,parameters_struct *parameters)
+{
+    LPSTR p;
+    LPSTR p2;
+   
+    p2 = commandline;
+    p = strchr(commandline,'/');
+    while(p)
+    {
+        p++;
+        if (strncmp(p,"n",1)==0)
+        {
+            parameters->explorer_mode = FALSE;
+            p++;
+        }
+        else if (strncmp(p,"e,",2)==0)
+        {
+            parameters->explorer_mode = TRUE;
+            p+=2;
+        }
+        else if (strncmp(p,"root,",5)==0)
+        {
+            p+=5;
+            p+=CopyPathString(parameters->root,p);
+        }
+        else if (strncmp(p,"select,",7)==0)
+        {
+            p+=7;
+            p+=CopyPathString(parameters->selection,p);
+            if (!parameters->root[0])
+                CopyPathRoot(parameters->root,
+                        parameters->selection);
+        }
+        p2 = p;
+        p = strchr(p,'/');
+    }
+    if (p2 && *p2)
+    {
+        /* left over command line is generally the path to be opened */
+        CopyPathString(parameters->root,p2);
+    }
+}
+
+int APIENTRY WinMain(HINSTANCE hinstance,
+					 HINSTANCE previnstance,
+					 LPSTR	   cmdline,
+					 int	   cmdshow)
+{
+    STARTUPINFOW si;
+    PROCESS_INFORMATION info;
+    parameters_struct   parameters;
+    BOOL rc;
+    static WCHAR winefile[] = {'w','i','n','e','f','i','l','e','.','e','x','e',0};
+
+    memset(&parameters,0,sizeof(parameters));
+    
+    memset(&si,0,sizeof(STARTUPINFOW));
+    memset(&info,0,sizeof(PROCESS_INFORMATION));
+
+    ParseCommandLine(cmdline,&parameters);
+
+    rc = CreateProcess(NULL, winefile, NULL, NULL, FALSE, 0, NULL,
+            parameters.root, &si, &info);
+    
+    if (!rc)
+        return 0;
+
+    WaitForSingleObject(info.hProcess,INFINITE);
+	return 0;
+}


More information about the wine-patches mailing list