131{
133 const char *pszOutputPath = "shortcut.lnk";
134 const char *pszTarget =
NULL;
135 const char *pszDescription = "Description";
136 const char *pszWorkingDir =
NULL;
137 const char *pszCmdLineArgs =
NULL;
138 const char *pszIcon =
NULL;
139 int IconNr = 0;
141 int bHelp = 0, bMinimized = 0;
146
148 {
152 bHelp = 1;
154 pszOutputPath =
argv[++
i];
156 pszDescription =
argv[++
i];
158 pszWorkingDir =
argv[++
i];
160 pszCmdLineArgs =
argv[++
i];
162 {
166 }
168 bMinimized = 1;
170 {
171 unsigned Data4Tmp[8],
j;
172
173 sscanf(
argv[++
i],
"{%8x-%4hx-%4hx-%2x%2x-%2x%2x%2x%2x%2x%2x}",
175 &Data4Tmp[0], &Data4Tmp[1], &Data4Tmp[2], &Data4Tmp[3],
176 &Data4Tmp[4], &Data4Tmp[5], &Data4Tmp[6], &Data4Tmp[7]);
177 for (
j = 0;
j < 8; ++
j)
179 }
180 else
182 }
183
184 if (!pszTarget || bHelp)
185 {
186 printf(
"Usage: %s [-o path][-d descr][-w path][-c cmd_line_args][-i icon_path [nr]][-h][-g guid] target\n"
187 "-o path\tSets output path\n"
188 "-d descr\tSets shortcut description\n"
189 "-w path\tSets working directory for executable\n"
190 "-c cmd_line_args\tSets command line arguments passed to program\n"
191 "-i icon_path [nr]\tSets icon file and optionally icon index\n"
192 "-m\tStart minimized\n"
193 "-g guid\tSets GUID to which target path is relative. Default value is MyComputer GUID.\n"
194 "target\tAbsolute or relative to guid specified with -g option path\n",
argv[0]);
195 return 0;
196 }
197
200 {
201 printf(
"Failed to open %s\n", pszOutputPath);
202 return -1;
203 }
204
205
208 Header.Guid = CLSID_ShellLink;
210 if (pszDescription)
212 if (pszWorkingDir)
214 if (pszCmdLineArgs)
216 if (pszIcon)
221
223 {
228 const char *pszName = pszTarget;
229
230
231
232
233 pszName = pszTarget;
234
235 if (pszName[0] && pszName[1] == ':')
236 {
237 cbListSize += sizeof(IdListDrive);
238 pszName += 2;
239 while (*pszName == '\\' || *pszName == '/')
240 ++pszName;
241 }
242
243 while (*pszName)
244 {
248
249 if (
cchName != 1 || pszName[0] !=
'.')
250 cbListSize +=
sizeof(IdListFile) + 2 * (
cchName + 1);
251
253 while (*pszName == '\\' || *pszName == '/')
254 ++pszName;
255 }
256
257 uhTmp = cbListSize;
259
260 IdListGuid.
Size =
sizeof(IdListGuid);
262 IdListGuid.
dummy = 0x50;
265
266 pszName = pszTarget;
267
268 if (
isalpha(pszName[0]) && pszName[1] ==
':')
269 {
270 memset(&IdListDrive, 0,
sizeof(IdListDrive));
271 IdListDrive.
Size =
sizeof(IdListDrive);
274 fwrite(&IdListDrive,
sizeof(IdListDrive), 1,
pFile);
275 pszName += 2;
276 while(*pszName == '\\' || *pszName == '/')
277 ++pszName;
278 }
279
280 while (*pszName)
281 {
285
286 if (
cchName != 1 || pszName[0] !=
'.')
287 {
288 memset(&IdListFile, 0,
sizeof(IdListFile));
289 IdListFile.
Size =
sizeof(IdListFile) + 2 * (
cchName + 1);
292 else
299 }
300
302 while (*pszName == '\\' || *pszName == '/')
303 ++pszName;
304 }
305
306 uhTmp = 0;
308 }
309
311 {
312
313 uhTmp =
strlen(pszDescription);
316 }
317
319 {
320
321 uhTmp =
strlen(pszTarget);
324 }
325
327 {
328
329 uhTmp =
strlen(pszWorkingDir);
332 }
333
335 {
336
337 uhTmp =
strlen(pszCmdLineArgs);
340 }
341
343 {
344
348 }
349
350
351 dwTmp = 0;
353
355
356 return 0;
357}
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
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 i
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)
#define LINK_RELATIVE_PATH
#define LINK_CMD_LINE_ARGS
#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