This task is to determine if there is only one instance of an application running. If the program discovers that an instance of it is already running, then it should display a message indicating that it is already running and exit.

-- demo\rosetta\Single_instance.exw
without js
include pGUI.e

function copydata_cb(Ihandle /*ih*/, atom pCommandLine, integer size)
    -- (the first instance is sent a copy of the second one's command line)
    printf(1,"COPYDATA(%s, %d)\n",{peek_string(pCommandLine), size});
    return IUP_DEFAULT;
end function

IupOpen()
IupSetGlobal("SINGLEINSTANCE", "Single") -- (must [partially] match the main window title)
if IupGetGlobal("SINGLEINSTANCE")!="" then
    Ihandle dlg = IupDialog(IupVbox({IupLabel("hello")},"MARGIN=200x200"))
    IupSetAttribute(dlg,"TITLE","Single Instance")
    IupSetCallback(dlg, "COPYDATA_CB", Icallback("copydata_cb"));
    IupShow(dlg)
    IupMainLoop()
end if
IupClose()
