180{
182 const char *pszOutputPath = "shortcut.lnk";
183 const char *pszTarget =
NULL;
184 const char *pszDescription =
NULL;
185 const char *pszWorkingDir =
NULL;
186 const char *pszCmdLineArgs =
NULL;
187 const char *pszIcon =
NULL;
188 char targetpath[260];
189 int IconNr = 0;
191 int bHelp = 0, bMinimized = 0;
197
199 {
203 bHelp = 1;
205 pszOutputPath =
argv[++
i];
207 pszDescription =
argv[++
i];
209 pszWorkingDir =
argv[++
i];
211 pszCmdLineArgs =
argv[++
i];
213 {
217 }
219 bMinimized = 1;
221 {
222 unsigned Data4Tmp[8],
j;
223
224 sscanf(
argv[++
i],
"{%8x-%4hx-%4hx-%2x%2x-%2x%2x%2x%2x%2x%2x}",
226 &Data4Tmp[0], &Data4Tmp[1], &Data4Tmp[2], &Data4Tmp[3],
227 &Data4Tmp[4], &Data4Tmp[5], &Data4Tmp[6], &Data4Tmp[7]);
228 for (
j = 0;
j < 8; ++
j)
230 }
231 else
233 }
234
235 if (!pszTarget || bHelp)
236 {
237 printf(
"Usage: %s [-o path][-d descr][-w path][-c cmd_line_args][-i icon_path [nr]][-h][-g guid] target\n"
238 "-o path\tSets output path\n"
239 "-d descr\tSets shortcut description\n"
240 "-w path\tSets working directory for executable\n"
241 "-c cmd_line_args\tSets command line arguments passed to program\n"
242 "-i icon_path [nr]\tSets icon file and optionally icon index\n"
243 "-m\tStart minimized\n"
244 "-g guid\tSets GUID to which target path is relative. Default value is MyComputer GUID.\n"
245 "target\tAbsolute or relative to guid specified with -g option path\n",
argv[0]);
246 return 0;
247 }
248
251 {
252 printf(
"Failed to open %s\n", pszOutputPath);
253 return -1;
254 }
255
256
259 Header.Guid = CLSID_ShellLink;
261 if (pszDescription)
263 if (pszWorkingDir)
265 if (pszCmdLineArgs)
267 if (pszIcon)
272
274 {
279 const char *pszName = pszTarget;
280 int index = 1, specialindex = -1;
282
283
284
285
286 if (special)
287 {
288 Header.Flags &= ~LINK_RELATIVE_PATH;
289 CsidlBlock.
cbSize =
sizeof(CsidlBlock);
292 specialindex = 3;
293 sprintf(targetpath,
"x:\\reactos\\%s", pszTarget +
sizeof(
"shell:") +
strlen(special->
name));
294 pszName = pszTarget = targetpath;
295 }
296
297 if (pszName[0] && pszName[0] != ':' && pszName[1] == ':')
298 {
300 cbListSize += sizeof(IdListDrive);
301 pszName += 2;
302 while (*pszName == '\\' || *pszName == '/')
303 ++pszName;
304 }
305
306 while (*pszName)
307 {
311
312 if (
cchName != 1 || pszName[0] !=
'.')
313 cbListSize +=
sizeof(IdListFile) + 2 * (
cchName + 1);
314
315 if (++
index == specialindex)
316 {
318 pCsidlBlock = &CsidlBlock;
319 }
320
322 while (*pszName == '\\' || *pszName == '/')
323 ++pszName;
324 }
325
326 uhTmp = cbListSize;
328
329 IdListGuid.
Size =
sizeof(IdListGuid);
331 IdListGuid.
dummy = 0x50;
334
335 pszName = pszTarget;
336
337 if (
isalpha(pszName[0]) && pszName[1] ==
':')
338 {
339 memset(&IdListDrive, 0,
sizeof(IdListDrive));
340 IdListDrive.
Size =
sizeof(IdListDrive);
343 fwrite(&IdListDrive,
sizeof(IdListDrive), 1,
pFile);
344 pszName += 2;
345 while(*pszName == '\\' || *pszName == '/')
346 ++pszName;
347 }
348
349 while (*pszName)
350 {
354
355 if (
cchName != 1 || pszName[0] !=
'.')
356 {
357 memset(&IdListFile, 0,
sizeof(IdListFile));
358 IdListFile.
Size =
sizeof(IdListFile) + 2 * (
cchName + 1);
361 else
368 }
369
371 while (*pszName == '\\' || *pszName == '/')
372 ++pszName;
373 }
374
375 uhTmp = 0;
377 }
378
380 {
381
382 uhTmp =
strlen(pszDescription);
385 }
386
388 {
389
390 uhTmp =
strlen(pszTarget);
393 }
394
396 {
397
398 uhTmp =
strlen(pszWorkingDir);
401 }
402
404 {
405
406 uhTmp =
strlen(pszCmdLineArgs);
409 }
410
412 {
413
417 }
418
419
420 if (pCsidlBlock)
421 fwrite(pCsidlBlock,
sizeof(*pCsidlBlock), 1,
pFile);
422 dwTmp = 0;
424
426
427 return 0;
428}
int strcmp(const char *String1, const char *String2)
unsigned short int uint16_t
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_opt_ _CRTIMP int __cdecl fputs(_In_z_ const char *_Str, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
static const struct SPECIALFOLDER * get_special_folder(const char *target)
#define LINK_RELATIVE_PATH
#define LINK_CMD_LINE_ARGS
#define EXP_SPECIAL_FOLDER_SIG
#define SW_SHOWMINNOACTIVE
#define sprintf(buf, format,...)
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName