Let say you have came out with a software written in c is there anyway to insert a clickable icon on your desktop so you can run the program on windows desktop? c is very good but we need to get a clickable icon so we can run our software.

Dani AI

Generated

As asks, a desktop "clickable icon" is just a shortcut or an executable with an embedded icon. is right that a manual shortcut works, and pointed toward adding an icon to the EXE. Below are practical, safe ways to create that desktop icon and what to watch for.

One common programmatic approach is to create a Windows Shell Link (.lnk) using the Shell COM interfaces (IShellLink / IPersistFile). The pattern is: initialize COM, create a CLSID_ShellLink, set path, arguments, description and icon, then save via IPersistFile to the user or public Desktop. Example (compile as C++ and link Ole32.lib / Shell32.lib):

#include <windows.h>
#include <shobjidl.h>   // IShellLinkW, IPersistFile
#include <shlguid.h>    // CLSID_ShellLink
#include <objbase.h>

int wmain()
{
    CoInitialize(NULL);
    IShellLinkW* psl = nullptr;
    if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
                                   IID_IShellLinkW, (void**)&psl)))
    {
        psl->SetPath(L"C:\\Path\\To\\YourExe.exe");
        psl->SetDescription(L"My App");
        psl->SetIconLocation(L"C:\\Path\\To\\YourExe.exe", 0);

        IPersistFile* ppf = nullptr;
        if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile, (void**)&ppf)))
        {
            ppf->Save(L"C:\\Users\\Public\\Desktop\\MyApp.lnk", TRUE);
            ppf->Release();
        }
        psl->Release();
    }
    CoUninitialize();
    return 0;
}

Embedding an icon into the EXE (resource script or IDE resource editor) makes Windows display that icon for the shortcut automatically. Use an installer (Inno/NSIS/MSI) to place per-user or all-users shortcuts correctly. Retrieve the correct Desktop path programmatically with SHGetKnownFolderPath / Known Folders rather than hardcoding.

Notes and cautions: prefer creating shortcuts during install rather than modifying desktops at runtime without consent; respect per-user vs Public desktop and UAC; modifying an installed EXE or programmatically writing files to other user profiles can trigger antivirus or break permissions. Microsoft docs on Shell Links and icon resources are the authoritative references: Shell Links and Using Icons.

Recommended Answers

All 2 Replies

I think it's called a shortcut. You can create it yourself on Windows and then maybe include it in your distribution.

Right click on your executable and you can create the shortcut.

is one way to add an icon to your C or C++ programs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.