@@ -266,13 +266,30 @@ static LPWSTR expand_variables(LPWSTR buffer, size_t alloc)
266
266
return buf ;
267
267
}
268
268
269
+ static void set_app_id (LPWSTR app_id )
270
+ {
271
+ HMODULE shell32 ;
272
+ HRESULT (* set_app_id )(LPWSTR app_id );
273
+
274
+ shell32 = LoadLibrary (L"shell32.dll" );
275
+ if (!shell32 )
276
+ return ;
277
+ set_app_id = (void * ) GetProcAddress (shell32 ,
278
+ "SetCurrentProcessExplicitAppUserModelID" );
279
+ if (!set_app_id )
280
+ return ;
281
+ if (!SUCCEEDED (set_app_id (app_id )))
282
+ print_error (L"warning: could not set app ID" , GetLastError ());
283
+ }
284
+
269
285
static int configure_via_resource (LPWSTR basename , LPWSTR exepath , LPWSTR exep ,
270
286
LPWSTR * prefix_args , int * prefix_args_len ,
271
287
int * is_git_command , LPWSTR * working_directory , int * full_path ,
272
288
int * skip_arguments , int * allocate_console , int * show_console )
273
289
{
274
290
int i , id , minimal_search_path , needs_a_console , no_hide , wargc ;
275
291
LPWSTR * wargv ;
292
+ WCHAR * app_id ;
276
293
277
294
#define BUFSIZE 65536
278
295
static WCHAR buf [BUFSIZE ];
@@ -283,6 +300,7 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
283
300
minimal_search_path = 0 ;
284
301
needs_a_console = 0 ;
285
302
no_hide = 0 ;
303
+ app_id = NULL ;
286
304
len = LoadString (NULL , id , buf , BUFSIZE );
287
305
288
306
if (!len ) {
@@ -307,6 +325,21 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
307
325
needs_a_console = 1 ;
308
326
else if (strip_prefix (buf , & len , L"SHOW_CONSOLE=1 " ))
309
327
no_hide = 1 ;
328
+ else if (strip_prefix (buf , & len , L"APP_ID=" )) {
329
+ LPWSTR space = wcschr (buf , L' ' );
330
+ size_t app_id_len = space - buf ;
331
+ if (!space ) {
332
+ len -= 7 ;
333
+ memmove (buf , buf + 7 ,
334
+ len * sizeof (WCHAR ));
335
+ break ;
336
+ }
337
+ app_id = wcsdup (buf );
338
+ app_id [app_id_len ] = L'\0' ;
339
+ len -= app_id_len + 1 ;
340
+ memmove (buf , buf + app_id_len + 1 ,
341
+ len * sizeof (WCHAR ));
342
+ }
310
343
else
311
344
break ;
312
345
}
@@ -325,6 +358,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
325
358
fwprintf (stderr ,
326
359
L"Skipping command-line '%s'\n('%s' not found)\n" ,
327
360
buf2 , exep );
361
+ if (app_id )
362
+ free (app_id );
328
363
}
329
364
330
365
* prefix_args = buf2 ;
@@ -366,6 +401,10 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
366
401
* skip_arguments = i ;
367
402
break ;
368
403
}
404
+ else if (!wcsncmp (L"--app-id=" , wargv [i ], 9 )) {
405
+ free (app_id );
406
+ app_id = wcsdup (wargv [i ] + 9 );
407
+ }
369
408
else
370
409
break ;
371
410
* skip_arguments = i ;
@@ -376,6 +415,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
376
415
* allocate_console = 1 ;
377
416
if (no_hide )
378
417
* show_console = 1 ;
418
+ if (app_id )
419
+ set_app_id (app_id );
379
420
LocalFree (wargv );
380
421
381
422
return 1 ;
0 commit comments