5
$\begingroup$

I just updated a small MathLink program that I made a while ago, and recompiled it using the new WSTP system (Mathematica 11.2).

The new version runs fine, but now this external WSTP program is shown in the taskbar (on Windows 10) once it's called via Install[], which was not the case with the old version that I created a while ago with the old MathLink system. On one of my computers, a (frozen) console window is shown when I click on the taskbar item, but on another system nothing happens when I click on that taskbar item...

Interestingly, this even happens for the pre-compiled WSTP programs supplied with Mathematica (for example the addtwo program described on the Install[] help page).

I build my program using VS 2017 using the instructions in the Mathematica documentation. I already tried this instruction to force the linker to use the "Windows" type instead of "Console", but it didn't change anything...

Any ideas on how one can get rid of these WSTP programs showing up in the taskbar?

$\endgroup$
  • 1
    $\begingroup$ If you follow the structure of the examples that come with Mathematica, the button will appear in the taskbar. This has always been the case. It has nothing to do with MathLink/WSTP updates. Perhaps try comparing your old program with the new one and see where the difference is. I would suspect the MLInitializeIcon part, but I am not very familiar with Windows anymore. If you want to compile in console mode, you'd use the main() function instead of WinMain, but then you'd get a console window, even worse than a taskbar button. $\endgroup$ – Szabolcs Feb 21 '18 at 22:46
  • $\begingroup$ Ok - didn't know that this was always the case for the standard programs! My old program used the main() function, but there was no console window... If I use the main() function in my updated version, I get a console window... so not sure where the problem is... I compiled the old version with MinGW though, so maybe using VS is the "problem"! $\endgroup$ – mjayvizzle Feb 21 '18 at 23:01
4
$\begingroup$

Turns out it was really simple and Szabolcs was right - removing the line

if (!WSInitializeIcon(hinstCurrent, nCmdShow)) return 1;

from the WinMain function in the standard WSTP C/C++ source file works, and no taskbar item is shown.

(Not sure why my old version, which used the main() function and was compiled with MinGW, didn't generate a console window or taskbar item though).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.