4 * Copyright 2005 CodeWeavers, Aric Stewart
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 typedef struct parametersTAG
{
27 WCHAR selection
[MAX_PATH
];
31 static int CopyPathString(LPWSTR target
, LPSTR source
)
33 CHAR temp_buf
[MAX_PATH
];
36 while (isspace(*source
)) source
++;
41 while (*source
!= '\"')
43 temp_buf
[i
] = *source
;
53 while (*source
&& !isspace(*source
))
55 temp_buf
[i
] = *source
;
61 MultiByteToWideChar(CP_ACP
,0,temp_buf
,-1,target
,MAX_PATH
);
66 static void CopyPathRoot(LPWSTR root
, LPWSTR path
)
75 while (*p
!='\\' && p
> path
)
92 * Command Line parameters are:
93 * [/n] Opens in single-paned view for each selected items. This is default
94 * [/e,] Uses Windows Explorer View
95 * [/root,object] Specifies the root level of the view
96 * [/select,object] parent folder is opened and specified object is selected
98 static void ParseCommandLine(LPSTR commandline
,parameters_struct
*parameters
)
104 p
= strchr(commandline
,'/');
108 if (strncmp(p
,"n",1)==0)
110 parameters
->explorer_mode
= FALSE
;
113 else if (strncmp(p
,"e,",2)==0)
115 parameters
->explorer_mode
= TRUE
;
118 else if (strncmp(p
,"root,",5)==0)
121 p
+=CopyPathString(parameters
->root
,p
);
123 else if (strncmp(p
,"select,",7)==0)
126 p
+=CopyPathString(parameters
->selection
,p
);
127 if (!parameters
->root
[0])
128 CopyPathRoot(parameters
->root
,
129 parameters
->selection
);
136 /* left over command line is generally the path to be opened */
137 CopyPathString(parameters
->root
,p2
);
141 int WINAPI
WinMain(HINSTANCE hinstance
,
142 HINSTANCE previnstance
,
147 PROCESS_INFORMATION info
;
148 parameters_struct parameters
;
150 static WCHAR winefile
[] = {'w','i','n','e','f','i','l','e','.','e','x','e',0};
152 memset(¶meters
,0,sizeof(parameters
));
153 memset(&si
,0,sizeof(STARTUPINFOW
));
155 ParseCommandLine(cmdline
,¶meters
);
157 rc
= CreateProcessW(NULL
, winefile
, NULL
, NULL
, FALSE
, 0, NULL
,
158 parameters
.root
, &si
, &info
);
163 WaitForSingleObject(info
.hProcess
,INFINITE
);